Product detection problem.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Product detection problem.

Post by Joe »

I have created an order form where new products can be added etc but I have bumped into a problem which I cannot seem to solve. When a new item is added to the database and the user selects it as a product for their cart, it is read as hidden fields on each form, just so the script can detect exactly which products have been selected. Now, on the finalconfirmation page which querys the customer details into the database I can not seem to detect new products which have been added. It is very confusing to explain this but im sure it can be worked out. I tried making a loop but instead of showing the products it shows the first product, "CD-Player" in every column. I thought it would have done that seen as the structure of the loop, nevertheless any help appreciated here. :)

Code: Select all

$sql1 = "SELECT * FROM dbproducts";
$result = mysql_query($sql1) or die(mysql_error());

while (true)
{
 $row = mysql_fetch_assoc($result);
 if ($row == false) break;
 $val = $row['product'];
 $val1 = str_replace(" ","-",$val);

 $i=0;
 do
 {
  $i++;
  $value[$i] = $_POST[$val1];
 }
 while($i<9);

$nextsql = "INSERT INTO dborderdetails VALUES('$fullname','$value[1]','$value[2]','$value[3]','$value[4]','$value[5]','$value[6]','$value[7]','$value[8]','$value[9]')";

mysql_query($nextsql) or die(mysql_error());
}
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

where does $fullname come from?
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Oh fullname is a variable I declared just above the loop, the name go's in fine, just the products!
Post Reply