This topic is locked

deleting record from another table problem

8/11/2008 9:35:12 PM
PHPRunner General questions
E
emsurban author

This is what I want to accomplish:
I have employee, printer, printerbox and scanbox table. What i want to do is when i delete an employee from employee table, it will look at employee's username in printer table then get the coresponding printbox and scanbox number of the employee, once i have the printebox and scanbox number of that employee, i will update printbox and scanbox table, then finally delete the employee from the printer table,
Please see that code below. Its not updating the printbox and scanbox table.
[codebox]//delete printer related records

$deldata = $deleted_values["username"];

$strSQLExists = "select from printer where username='$deldata'";

$rsExists = db_query($strSQLExists,$conn);

$datafordel=db_fetch_array($rsExists);
if($datafordel){
// updating printerbox table

$printboxdata = $datafordel["printbox"];

$strSQLExistsPB = "select
from printbox where printbox='$printboxdata'";

$rsExistsPB = db_query($strSQLExistsPB,$conn);

$printboxdatafound = db_fetch_array($rsExistsPB);
$printboxdatafoundPB = $printboxdatafound["printbox"];

$strSQLUpdatePB = "update printbox set status='Available' where printbox='$printboxdatafoundPB'";

db_exec($strSQLUpdatePB,$conn);
// updating scannerbox table

$scanboxdata = $datafordel["scanbox"];

$strSQLExistsSB = "select * from scanbox where scanbox='$scanboxdata'";

$rsExistsSB = db_query($strSQLExistsSB,$conn);

$scanboxdatafound = db_fetch_array($rsExistsSB);
$scanboxdatafoundSB = $scanboxdatafound["scanbox"];

$strSQLUpdateSB = "update scanbox set status='Available' where scanbox='$scanboxdatafoundSB'";

db_exec($strSQLUpdatePB,$conn);
// delete user from printer

$printerdata = $deleted_values["username"];

$strSQLDeleteP = "delete from printer where username='$printerdata'";

db_exec($strSQLDeleteP,$conn);
}[/codebox]

J
Jane 8/12/2008

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.