simple coding question
Posted: Tue Oct 04, 2005 8:04 pm
Hi i just need a little help with this code.
what i want to happen here is that i want to insert a value on the prodTotal column one at a time for the duration of this loop...
currently my code is unable to do that. can you help me figure it out? thank you!
Code: Select all
$dbCon = mysql_connect ("host","user","password") ;
$dbUse = mysql_select_db("orderdb", $dbCon) ;
$amtQuery = "select prodAmount from ordercart" ;
$amtResult = mysql_query ($amtQuery,$dbCon) ;
$qtyQuery = "select prodQuantity from ordercart" ;
$qtyResult = mysql_query ($qtyQuery,$dbCon) ;
$qtyRow = mysql_num_rows ($qtyQuery) ;
$amt = mysql_fetch_array($amtResult) ;
$qty = mysql_fetch_array($qtyResult) ;
$total = array() ;
for ($count = 0;$count < $qtyRow;$count++)
{
$total[$count] = $amt[$count] * $qty[$count] ;
$totQuery = "insert into ordercart (prodTotal) values ($total[$count])" ;
$totResult = mysql_query ($totQuery,$dbCon) ;
}
mysql_close($dbCon) ;Code: Select all
for ($count = 0;$count < $qtyRow;$count++)
{
$total[$count] = $amt[$count] * $qty[$count] ;
$totQuery = "insert into ordercart (prodTotal) values ($total[$count])" ;
$totResult = mysql_query ($totQuery,$dbCon) ;
}