Re: Using one submit button
| From: | Jennifer Downey | Date: | Wed, 17 Apr 2002 02:32:40 +0000 |
| Subject: | Re: Using one submit button | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-93279@lists.php.net to get a copy of this message | ||
Do you mean something like this?
if($update)
{
$iprice = $price["price"];
$query = "UPDATE {$config["prefix"]}_shop SET price = $iprice where uid =
{$session["uid"]} AND id = $id";
$ret = mysql_query($query);
}
"Martin Towell" <martin.towell@world.net> wrote in message
news:6416776FCC55D511BC4E0090274EFEF508A1C9@exchange.world.net...
> user price[] as the name
> you'll also need to pass the ids as $id[]
> so you know which one you're updating
>
> -----Original Message-----
> From: Jennifer Downey [mailto:jendowney@attbi.com]
> Sent: Wednesday, April 17, 2002 11:51 AM
> To: php-general@lists.php.net
> Subject: [PHP] Using one submit button
>
>
> 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
>
>
>
> --
> 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