hi folks,
i am trying to call a php function using a button. have created a menu from entries in a mysql database using a loop. my buttons are also generated using this loop.....i have an add button for every entry to allow users to select items. my problem is that my php function is called everytime the loop executes...and without even clicking the buttons my database gets filled....hope this makes sense! i have included my code below in the hope that someone can help!
<?php
$dbQuery="SELECT * FROM stock";
$result = mysql_query($dbQuery,$db);
while ($stockInfo=mysql_fetch_array($result)) {
$image='<img src="images/'.$stockInfo["image"].'" width="75" height="75">';
$name=$stockInfo["name"];
$ingredients=$stockInfo["ingredients"];
$price=$stockInfo["price"].'0';
?>
<tr align=center>
<td><?php echo "$image" ?></td>
<td><?php echo "$name" ?></td>
<td><?php echo "$ingredients" ?></td>
<td><?php echo "$price" ?></td>
<td><input type="button" value="Add" onclick="<?php $myCart->addItem("$name", "$price" )?>"></td>
</tr>
<?php
}
$myCart->addToDatabase();
?>
i would be very grateful for any suggestions! thanks