Re: Using one submit button
| From: | Jennifer Downey | Date: | Wed, 17 Apr 2002 16:11:19 +0000 |
| Subject: | Re: Using one submit button | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-93344@lists.php.net to get a copy of this message | ||
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" <jendowney@attbi.com> wrote in message
news:20020417015145.28218.qmail@pb1.pair.com...
> 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