Thank you Jason and Kevin for your time and help. Does this look like what I should have?
if(isset($update)) for ($i=0; $i<count($id); $i++) { if ($id[$i] == $row[id]) { $query = "UPDATE {$config["prefix"]}_shop SET price = $price[$i] where uid = {$session["uid"]} AND id = $id[$i]"; $ret = mysql_query($query) or die(mysql_error()); } else { echo "<TD width=30%><font size=2><CENTER><input=\"hidden\" name=\"id[$i]\" value=\"$id\"><input type=\"text\" value=\"\" name=\"price[$i]\" size='8' MAXLENGTH='8'><BR></a></CENTER></font></TD>"; Jennifer "Kevin Stone" <[EMAIL PROTECTED]> wrote in message 004301c1e633$e1e20090$6601a8c0@kevin">news:004301c1e633$e1e20090$6601a8c0@kevin... > ------------- > I picked up your question soon after you submited it then my internet went > down so I wasn't able to send it. Looks like it's been answered by someone > else since then but here you go anyway. I didn't want to feel as though I'd > wasted my time. :D > -kevin > ------------- > > Looks like you want to extract the values from the $price array in the same > order as you extracted the associated rows from the database. At first > glance I can say you aren't passing enough information to be able to > determine an order for updating. You'll need to send the product ids along > with the prices and then create a counter to loop through the ids array and > test each case. > > I would sugget you build an $id[] list the same way as the $price[] list but > generate them as hidden fields. Then within the if(isset($update)) > statement loop through all $id values for each itteration of the while > loop... > > for ($i=0; $i<count($id); $i++) > { > if ($id[$i] == $row[id]) > { > // we know that there are the same number of ids as there are prices > so we can use $i for the $price index as well. > $query = "UPDATE $table SET price = $price[$i] WHERE id = $id[$i]"; > // do update.. > } > } > > -Kevin > > ----- Original Message ----- > From: "Jennifer Downey" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, April 17, 2002 10:11 AM > Subject: [PHP] Re: Using one submit button > > > > I have no takers on this one? > > > > Just to let you know I have been working on this to here is some new code. > > What I need this to do is update the price in the db table. > > if I have on item it is fine. If I have two items it won't update the > first > > items price but will the second. if I try to enter a price in the first > > items textbox it doesn't update and then deletes the second item's price. > > > > If I have 15 items and using one submit button how do I get this to > update > > all items that are listed? > > > > $query = "SELECT uid, id, name, image, type, quantity, price FROM > > {$config["prefix"]}_shop WHERE uid = {$session["uid"]}"; > > $ret = mysql_query($query); > > while($row = mysql_fetch_array($ret)) > > { > > $uid = $row['uid']; > > $id = $row['id']; > > $name = $row['name']; > > $image = $row['image']; > > $iquantity = $row['quantity']; > > $itype = $row['type']; > > $iprice = $row['price']; > > > > if($update) > > { > > $eprice = '$price[]'; > > $query = "UPDATE {$config["prefix"]}_shop SET price = '$eprice' > > where uid = {$session["uid"]} AND id = '$id'"; > > $ret = mysql_query($query) or die(mysql_error()); > > } > > else > > { > > > > echo "<TABLE BORDER='0' WIDTH='95%' CELLPADDING='0' > > CELLSPACING='0'><TR>"; > > echo "<TD width=20%><img src='$image'></TD>"; > > echo "<TD width=30%><font size=2>$name</font></TD>"; > > echo "<TD width=20%><font > > size=2><CENTER>$iquantity</CENTER></font></TD>"; > > echo "<TD width=30%><font size=2><CENTER><a > > href='$PHP_SELF?id=$id&remove=yes'>X</a></CENTER></font></TD>"; > > echo "<TD width=30%><font size=2><CENTER><input type=\"text\" > > value=\"\" name=\"price[]\" size='8' > > MAXLENGTH='8'><BR></a></CENTER></font></TD>"; > > echo "</TD></TR></TABLE>"; > > echo "<input=\"hidden\" name=\"remove\" value=\"yes\">"; > > } > > } > > echo "<CENTER><INPUT TYPE=\"submit\" NAME=\"update\" VALUE=\"Updat > > Prices\">"; > > echo "</form>"; > > "Jennifer Downey" <[EMAIL PROTECTED]> wrote in message > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > Hi all, > > > > > > I thought I was going to give php a break today but I can't it's too > > > adicting. > > > > > > I am having a little problem with a submit button in which it is suppose > > to > > > update records from a form. > > > > > > Here is the code > > > > > > > -------------------------------------------------------------------------- > > -- > > > ---- > > > > > > > > > echo "<BR><BR><a href=\"locker.php\">My Locker</a> | <a > > > href=\"myshop.php\">My Shop</a> | <a href=\"items.php\">My > > > Items</a><BR><BR>"; > > > echo "<TABLE BORDER='0' WIDTH='95%' CELLPADDING='0' > > CELLSPACING='0'><TR><TD > > > width=20%><B><font size=2>Image</font></B></TD><TD width=30%><B><font > > > size=2>Name</font></B></TD><TD width=20%><B><font > > > size=2><CENTER>Quantity</CENTER></font></B></TD><TD width=30%><B><font > > > size=2><CENTER>Remove Item</CENTER></font></B></TD><TD > width=30%><B><font > > > size=2><CENTER>Price</CENTER></font></B></TD></TR></table>"; > > > echo "<FORM action='$PHP_SELF' METHOD='post'>"; > > > > > > $query = "SELECT uid, id, name, image, type, quantity FROM > > > {$config["prefix"]}_shop WHERE uid = {$session["uid"]}"; > > > $ret = mysql_query($query); > > > while($row = mysql_fetch_array($ret)) > > > { > > > $uid = $row['uid']; > > > $id = $row['id']; > > > $name = $row['name']; > > > $image = $row['image']; > > > $iquantity = $row['quantity']; > > > $itype = $row['type']; > > > > > > > > > echo "<TABLE BORDER='0' WIDTH='95%' CELLPADDING='0' > > > CELLSPACING='0'><TR>"; > > > echo "<TD width=20%><img src='$image'></TD>"; > > > echo "<TD width=30%><font size=2>$name</font></TD>"; > > > echo "<TD width=20%><font > > > size=2><CENTER>$iquantity</CENTER></font></TD>"; > > > echo "<TD width=30%><font size=2><CENTER><a > > > href='$PHP_SELF?id=$id&remove=yes'>X</a></CENTER></font></TD>"; > > > echo "<TD width=30%><font size=2><CENTER><input > type=\"text\" > > > value=\"\" name=\"price\" size='6' > > > MAXLENGTH='8'><BR></a></CENTER></font></TD>"; > > > echo "</TD></TR></TABLE>"; > > > > > > echo "<input=\"hidden\" name=\"remove\" value=\"yes\">"; > > > } > > > echo "<CENTER><INPUT TYPE=\"submit\" NAME=\"update\" VALUE=\"Updat > > > Prices\">"; > > > echo "</form>"; > > > if($update) > > > { > > > $query = "UPDATE {$config["prefix"]}_shop SET price = '$price' > > > where uid = {$session["uid"]}"; > > > $ret = mysql_query($query); > > > } > > > > > > > > > > > > > -------------------------------------------------------------------------- > > -- > > > ---- > > > > > > > > > > > > What I need this to do is update the price in the db table. > > > if I have on item it is fine. If I have two items it won't update the > > first > > > items price but will the second. if I try to enter a price in the first > > > items textbox it doesn't update and then deletes the second item's > price. > > > > > > If I have 15 items and using one submit button how do I get this to > update > > > all items that are listed? > > > > > > TIA > > > Jennifer > > > > > > -- > > > The sleeper has awaken > > > > > > > > > --- > > > Outgoing mail is certified Virus Free. > > > Checked by AVG anti-virus system (http://www.grisoft.com). > > > Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002 > > > > > > > > > > > > --- > > Outgoing mail is certified Virus Free. > > Checked by AVG anti-virus system (http://www.grisoft.com). > > Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002 > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.344 / Virus Database: 191 - Release Date: 4/2/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php