Jump to content

NEED HELP PLZZ ON HIDDEN VALUES


ali_2kool2002

Recommended Posts

Hi im using a while loop to go through my query from the database. I get a product id and store it to the variable  using this line $productId = $results['productId']; I then try printing it on screen the value and comes up with 1, 2, 3, 4, which is correct but when i just enter it in the hidden input value it just only sends the value 4 which is the last value to the handeling form... If anyone can help or is on msn messenger i could send the files as im new to this im not sure how to send files here so add me plz sexiguy4u007@hotmail.com (sorry about the name ,,,lol only msn addy i hv)

 

 

HOPE SOME1 OUT THERE CAN HELP ME ,,,

cheers

 

 

 

 

 

 

 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?
//connect to the DB
session_start();

require_once('mysql_connect.php');
$display_block = "<h1>PRODUCTS - Product Detail</h1>";

//validate item
$get_item = "select c.catId as catId, c.cat_name, p.productId,p.productName, p.price, p.productDescription, p.image from product as p left join 
category as c on c.catId = p.catId";

$get_item_res = mysql_query($get_item) or die(mysql_error());

if ($get_item_res) {



echo '<table align="center" cellspacing="1" cellpadding="5">
<tr><td align="left"><b>Cat Id</b></td>
<td align="center"><b>  Category Name</b></td>
<td align="center"><b>  Item Name</b></td>
<td align="center"><b>  Item Description</b></td>
<td align="center"><b>  Images</b></td>
<td align="center"><b>  Price</b></td>
</tr></table>';

while ($results = mysql_fetch_array($get_item_res, MYSQL_ASSOC))
      { 
//variable to hold image file name from array
extract($results);
$image = $results['image']  ;	
//variable to hold productId from array
$productId = $results['productId'];


echo $productId;
echo '<form method = post action="addtocart.php">';									

echo'<INPUT TYPE ="submit" name = "submit" value = "Add to Cart" maxlength "50">
<input type="hidden" name="sel_item_id" value="'.$productId.'">';


}
//	echo '</table>';
//echo $display_block;
} else 
{ // If it did not run OK.
echo '<p>The current products could not be retrieved.
We apologize for any inconvenience.</p>'; 
echo '<p>' . mysql_error() . '</p>';
}
mysql_close(); 


?>


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>



Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.