This topic is locked

Continue Update After Record Updated

1/11/2009 8:02:38 PM
PHPRunner General questions
C
chaintm author

This is probably very simple, but I am missing it. I wrote the following code. Works well for my first line in the inventory, however it doesn't finish the rest. IE< just does the first itemized invoice item then stops. I need ofcourse to have it complete the full order. This (if not obvious) returns rented inventory back the order once the user selects a pulldown menu to close the invoice.
[codebox]//-------------------------Update Invoice Statues 2=active,3=closed,4=cancelled,5=passdue ------//

if($values["Order_status"]==3)

{

global $conn;

$str10 = "select from order_items where Order_num=".$keys["Order_num"];

$rs10 = CustomQuery($str10);

$data10 = db_fetch_array($rs10);

$str12 = "select
from order_items where ItemID='".$data10["ItemID"]."'";

$rs12 = CustomQuery($str12);

$data12 = db_fetch_array($rs12);

$str13 = "select * from items where ItemID='".$data10["ItemID"]."'";

$rs13 = CustomQuery($str13);

$data13 = db_fetch_array($rs13);

$strUpdate = "Update items set ItemStock=".$data13["ItemStock"]." + ".$data12["Qty_order"]." where ItemID='".$data10["ItemID"]."'";

db_exec($strUpdate,$conn);

}[/codebox]
I think it has to do with the type of update command I am using, need to array it? Errr,, something like that, give example please if you could my mind is mush atm <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=10610&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />

C
chaintm author 1/11/2009

This could be accomplished with a query statement could it not?

C
chaintm author 1/12/2009

been looking into this, hmm would I not be able to basicly loop this with the where statement which looks up the particular items?
//-------------------------Update Invoice Statues 2=active,3=closed,4=cancelled,5=passdue ------//

if($values["Order_status"]==3)

{

global $conn;

$str10 = "select from order_items where Order_num=".$keys["Order_num"];

$rs10 = CustomQuery($str10);

$data10 = db_fetch_array($rs10);

$str12 = "select
from order_items where ItemID='".$data10["ItemID"]."'";

$rs12 = CustomQuery($str12);

$data12 = db_fetch_array($rs12);

$str13 = "select * from items where ItemID='".$data10["ItemID"]."'";

$rs13 = CustomQuery($str13);

$data13 = db_fetch_array($rs13);

$strUpdate = "Update items set ItemStock=".$data13["ItemStock"]." + ".$data12["Qty_order"]." where ItemID='".$data13["ItemID"]."'";

db_exec($strUpdate,$conn);

}
doing this, ofcourse still only changes the first part, but the more I look into it, it seems there is a way to use where statements to call the correct fields using what I have done above, I know I am sooo close, it's driving me nuts hehe.

J
Jane 1/13/2009

Please see my changes in Bold:

if($values["Order_status"]==3)

{

global $conn;

$str10 = "select from order_items where Order_num=".$keys["Order_num"];

$rs10 = CustomQuery($str10);

while($data10 = db_fetch_array($rs10))

{

$str12 = "select
from order_items where ItemID='".$data10["ItemID"]."'";

$rs12 = CustomQuery($str12);

$data12 = db_fetch_array($rs12);

$str13 = "select * from items where ItemID='".$data10["ItemID"]."'";

$rs13 = CustomQuery($str13);

$data13 = db_fetch_array($rs13);

$strUpdate = "Update items set ItemStock=".$data13["ItemStock"]." + ".$data12["Qty_order"]." where ItemID='".$data13["ItemID"]."'";

db_exec($strUpdate,$conn);

}

}

C
chaintm author 1/13/2009

Ahh the While statement, ee gads! I knew it was something easy! hehe thnx again Jane, the master of all code <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=36778&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />