Forum Moderators: coopster
<?
error_reporting(E_ALL ¦ E_NOTICE);
include('connect.php');
$sql="SELECT * FROM PRODUCT";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query))
{ echo"<tr>";
echo "<td>".$row['prodtitle']."</td>";
echo "<td>".$row['proddescription']."</td>";
echo "<td>$".$row['prodcost'].".00</td><td>";
?>
<form action='cart.php' method='post'>
<input type='hidden' name='add2cart' value='<? $row['pid']?>'>
<input type='submit' name='addButton' value='Add to Cart'>
</form>
</td>
</tr>
<?
}
?>
The pid is correctly in the db and is being retrieved, however I do not know how to get the variable outside of a php block.
The example output i get is:
<tr><td>Product1</td><td>Amazing product1!</td><td>$20.00</td><td> <form action='cart.php' method='post'>
<input type='hidden' name='add2cart' value=''>
<input type='submit' name='addButton' value='Add to Cart'>
Note the hidden input type value is empty...ARGH!
I'm doing this to add an 'add2cart' button to each row of the table.
But I cannot seem to embed the html within the php block due to some
issues with quotations that I cannot resolve, or its something else;
I'm uncertain. I get no mysql_error() but just a blank page.
Can anyone assist me here?
On the other issue with quotes(I assume)...heres the example:
Now that I look at it, I've been up for 27 hours, it was total gibberish! What you helped me with already solves all my problems, except sleep! Thanks again!
[edited by: PickleHead at 10:06 am (utc) on May 30, 2007]
And Welcome to WebmasterWorld! :)