This topic is locked

SQL Update other Table

3/11/2008 4:05:21 AM
PHPRunner General questions
mic'',) author

Hi may I ask is this possible? I tried it already but it seems nothing happen.

Any help on this... Thanks.
// After record updated

function AfterEdit(&$values, $where, &$oldvalues, &$keys,$inline)

{

global $conn;

$str="SELECT asset_id, count(asset_id) number FROM asset_repair WHERE asset_id='".$values['asset_id']."' and status <> 'Closed' GROUP by asset_id";

$rs=db_query($str,$conn);

$data=db_fetch_array($rs);
if($data['number']!=0)

{

$strSQLUpdate = "UPDATE asset SET status='In Used' WHERE id='".$values['asset_id']."'";

db_exec($strSQLUpdate,$conn);

}

else

{

$strSQLUpdate = "UPDATE asset SET status='For Repair' WHERE id='".$values['asset_id']."'";

db_exec($strSQLUpdate,$conn);

}

} // function AfterEdit

J
Jane 3/11/2008

Hi,
try to use this code:

global $conn;

$str="SELECT count(asset_id) as number FROM asset_repair WHERE asset_id='".$values['asset_id']."' and status <> 'Closed' GROUP by asset_id";

$rs=db_query($str,$conn);

$data=db_fetch_numarray($rs);
if($data[0]!=0)

{

$strSQLUpdate = "UPDATE asset SET status='In Used' WHERE id='".$values['asset_id']."'";

db_exec($strSQLUpdate,$conn);

}

else

{

$strSQLUpdate = "UPDATE asset SET status='For Repair' WHERE id='".$values['asset_id']."'";

db_exec($strSQLUpdate,$conn);

}

mic'',) author 3/12/2008

Hi,
Jane your code doesn't work, my point of this when I update the asset_repair table it will update the asset table automatically if found record in the asset_repair which is <> to 'Closed'.
Anyhow thanks for the reply I still thinking for the other possibilities

J
Jane 3/12/2008

Hi,
it's difficult to tell you what's happening without seeing actual files.
You can 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 try to help you.

mic'',) author 3/13/2008

Hi,
OK here the URL http://demo.asprunner.net/mstolentino%5Fgm...m/mis/login.php
If I have pending job orders the status of the Asset becomes "For Repair"

mic'',) author 3/13/2008

Actually I made in add new Job Orders after add, the Asset becomes "For Repair" status, I don't know why code doen't work in after edit. Or the other option I want is if there is no Pending Order the Asset status becomes "In Use" else the status is "For Repair"
Thanks in advance.

J
Jane 3/13/2008

Hi,
first there are some errors in your code.

Please check my event code more carefully.
For more detailed description send link to your pages with your problem to [email=support@xlinesoft.com]support@xlinesoft.com[/email].