En curso

PHP PDO delete a record from multiple tables

I have the following tables and rows:

incident

incident_id

persons

person-id

incident_id

offense_charged

offense_id

incident_id

property

property_id

incident_id

vehicle

vehicle_id

incident_id

narrative

narrative_id

incident_id

there are other rows in these tables but not need for this project’s needs.

I am using php with pdo and when I delete a record in the incident table based on the incident_id, I want any of the tables listed (persons, offense_charged, property, vehicle, narrative) that have the same incident_id for those rows to be deleted also.

I have tried this:

<?php

include('../[url removed, login to view]');

if(isset($_GET['incident_id'])&&isset($_GET['case_number'])){

$incident_id = $_GET['incident_id'];

$case_number = $_GET['case_number'];

$sql = "DELETE FROM incident_location, person, offense_charged, property, vehicle, narrative WHERE incident_id = :incident_id AND case_number = :case_number";

$query = $handler->prepare($sql);

$query->execute(array(

':incident_id' => $incident_id,

':case_number' => $case_number

));

}

header("location: ../[url removed, login to view]");

?>

This is obviously not working.. I believe it will have to be a joined but am looking for suggestions.

Only bids that can do this now will be considered.. Today.......

I have the following tables and rows:

incident
incident_id

persons
person-id
incident_id
case_number

offense_charged
offense_id
incident_id
case_number

property
property_id
incident_id
case_number

vehicle
vehicle_id
incident_id
case_number

narrative
narrative_id
incident_id
case_number

there are other rows in these tables but not need for this project’s needs.

I am using php with pdo and when I delete a record in the incident table based on the incident_id, I want any of the tables listed (persons, offense_charged, property, vehicle, narrative) that have the same incident_id for those rows to be deleted also.

I have tried this:

<?php
include('../dbconfig.php');

if(isset($_GET['incident_id'])&&isset($_GET['case_number'])){

$incident_id = $_GET['incident_id'];
$case_number = $_GET['case_number'];

$sql = "DELETE FROM incident_location, person, offense_charged, property, vehicle, narrative WHERE incident_id = :incident_id AND case_number = :case_number";
$query = $handler->prepare($sql);
$query->execute(array(

':incident_id' => $incident_id,
':case_number' => $case_number


));

}

header("location: ../index.php");

?>

This is obviously not working.. I believe it will have to be a joined but am looking for suggestions.

Habilidades: MySQL, PHP

Ver más: project handler, shopping cart multiple tables php, php shopping cart multiple tables, record delete functionality php, multiple delete checkbox php, php search multiple tables script, delete record within hour php, delete record delete function php, multiple delete checkboxes php, delete record using javascript php, multiple file upload using ajax php java

Información del empleador:
( 43 comentarios ) Port Charlotte, United States

ID de proyecto: #9104227

Adjudicado a:

amin6106

Hi there, You should write separate delete queries for each table. Also do you have case number in all tables ? Thanks, Amin

$30 USD en 0 días
(40 comentarios)
5.3

21 los freelancers están ofertando un promedio de $50 para este trabajo.

coolguyinus2004

let me finish it for you. 11+ years of experience in programming PHP/MYSQL/API/WEB SCRAPING/DEBUG EXPERT/ANY KIND OF FIX IN [url removed, login to view] PHP CODING You can check my profile for my reputation and ranking .

$45 USD en 1 día
(331 comentarios)
7.6
alyaspk

Dear Employer, I am ready to work on your required task and can assure 100% satisfaction. You can read reviews/details about my past work on my profile [url removed, login to view] Looking forward to Más

$59 USD en 1 día
(93 comentarios)
6.7
usuf001

Hi I can code the query. need hosting access to start the work. thank you. syed.

$56 USD en 0 días
(366 comentarios)
6.7
shahid864

Hi, My name is Shahid, i am working in web development from past five years. Will provide you quality work and hopefully we will have long term relationship in web development. Let me know if i can help you. Thank Más

$45 USD en 1 día
(151 comentarios)
5.8
ryonkol

Experienced PHP/MySQL here, can provide exactly what you need, need phpMyAdmin access to do the same. Thanks

$75 USD en 1 día
(49 comentarios)
5.1
Torricelli

Hi, i hope you're doing well. I've just read your project's description and i would like to help you with it. I'm an experienced web developer with the necessary SQL skills for getting this job done. Responsib Más

$20 USD en 0 días
(50 comentarios)
4.8
mvaqasuddin

hi there provide me ftp details so I can review and fix it now, I am ready to start work on this PM me right away. Thanks

$61 USD en 1 día
(32 comentarios)
4.4
muamerETS

Hello, I'm interested with your project. I am Muamer. I'm a talented and creative web developer and designer from Bosnia and Herzegovina, with 8 years of experience in different directions web designing and web p Más

$30 USD en 1 día
(27 comentarios)
4.2
webprog4hire

hi i m expert in it and able to complete your work in 3 hours if interested so chat here refer my feedback & reviews

$111 USD en 1 día
(16 comentarios)
4.1
ysc2011

Hello sir i can do the task for you .

$15 USD en 0 días
(5 comentarios)
3.6
pynetvn

A proposal has not yet been provided

$61 USD en 0 días
(18 comentarios)
3.7
SophiaWalker

Hi, I have read your project description and project carefully,You looking a WEB DESIGNER and Cake PHP developer for your project. I'm very Professionally in Cake PHP and i have done very good webs application in Más

$100 USD en 1 día
(6 comentarios)
4.2
WestEastDevs

Hey there ! We're 2 developers with over 15 years of experience in PHP and Web Developing. Contact us for further details.

$83 USD en 1 día
(2 comentarios)
3.0
tenspark

UNLIMITED REVISIONS UNTIL YOU ARE 100% SATISFIED Hope you are well. I have read job description but I have some questions? Can we discuss in details before we start? to have the best deliverables for your project. I Más

$10 USD en 1 día
(1 comentario)
0.4
rlo56467a9097547

Hi there chose me ! i can help u Tks

$61 USD en 0 días
(1 comentario)
0.4
khannouman

Hello We work for quality products with highest level of professionals, we work with Web Development,Desktop app. We are producing high level software products with client satisfaction as the most prior attribute Más

$50 USD en 1 día
(0 comentarios)
0.0
plided

I can do right now...................................................................................................................................................

$30 USD en 0 días
(0 comentarios)
0.0
candhan

I have personally done a project on Patient Maintenance for my father using PHP for the backend and MySQL as the database. And I'm sure I can sort out your problem.

$25 USD en 1 día
(0 comentarios)
0.0
ZishanChuhan

A proposal has not yet been provided

$61 USD en 1 día
(0 comentarios)
0.0
daanjanssen

I can do this for you. I have 3 years experience with PHP and 2 year experience with MySQL. I hope you will agree!

$30 USD en 1 día
(0 comentarios)
0.0