Hello Jenniffer,
I think the you could do like this:
<form action="buyitem.php" method="post">
<?php
// selects the image,name,quantity,price of the item from db
$query = "SELECT * FROM items where id = $id";
$ret = mysql_query($query);
if ( $ret && mysql_num_rows($ret) )
{
while(list($result) =mysql_fetch_array($ret))
{
echo "<input type=image src=images/blueholo.gif
name=\".$result['id']."\"><BR>"; \\ The current id selected in the DB
echo "<B>".$result['name']."</B>"; \\ it will print the name of product
echo "Quantity ".$result['quantity']."<BR>"; \\ and the quantity
echo "Cost: ".$result['price']." SC"; \\ price as well
echo "<INPUT TYPE=\"hidden\" name=\"item_type\"
value=\"".$result[''item_type].">"; \\ i don't know if if will be necessary
but it won't appear in the Browser :)
}
}
?>
</form>
i thinkk it's good
At 19:33 31/03/02 -0800, you wrote:
>Hi all,
>
>I have a table called items here is a dump:
>
>CREATE TABLE items (
> id int(10) NOT NULL auto_increment,
> name varchar(50) NOT NULL default '',
> item_type int(4) NOT NULL default '0',
> image varchar(100) NOT NULL default '',
> price int(10) NOT NULL default '0',
> quantity int(5) NOT NULL default '0',
> PRIMARY KEY (id)
>) TYPE=MyISAM;
>
>Here is my code and I know there has to be an easier way to do this so any
>help would be appreciated.
>
><form action="buyitem.php" method="post">
>
><?php
>// selects the image of the item from db
>$query = "SELECT image FROM items where id = 1";
> $ret = mysql_query($query);
> while(list($image) =
> mysql_fetch_row($ret))
> echo "<input type=image src=images/blueholo.gif name=\"1\"><BR>";
>
>//select the name of the item
>$query = "SELECT name FROM items where id = 1";
> $ret = mysql_query($query);
> while(list($name) =
> mysql_fetch_row($ret))
>echo "<B>$name</B>";
>
>//shows the quantity of the item
>$query = "SELECT quantity FROM items where id = 1";
> $ret = mysql_query($query);
> while(list($quantity) =
> mysql_fetch_row($ret))
>echo "Quantity $quantity<BR>";
>
>//the price of the item
>$query = "SELECT price FROM items where id = 1";
> $ret = mysql_query($query);
> while(list($price) =
> mysql_fetch_row($ret))
>echo "Cost: $price SC";
>?>
></form>
>
>What I am trying to do is make it so the user clicks on the image and is
>taken to buyitem.php through the form where it takes the item out of the
>items table and updates the user table with that item.
>
>Any ideas how I can accomplish this?
>
>TIA
>Jennifer
>
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
Henrique Flach Latorre Moreno
Smart Tech Consulting
www.smartech.com.br
Av. Rio Branco 181, 1005
Centro - Rio de Janeiro - RJ
Tels : (21) 2532-6335
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php