I am developing a wish list website using PHP and MySQL that displays products in a table. The user has the option to add each product to their own wish list.
I can display the products no problem but once the user clicks on the option to add to their own list I am getting nothing. The server I am running on also does not flag an error so I have no idea what I am doing wrong.
Any help would be greatly appreciated. I have included the code below.
<?php
//connect to db
include('base.php');
//get results from db
$result = mysql_query("SELECT * FROM coffee_machines")
or die(mysql_error());
echo "<table border= '1' cellpadding='10'>";
echo "<tr> <th>ID</th> <th>Brand</th> <th>Description</th> <th>Price(£)</th> <th>image</th> </tr>";
$img_url = "http://localhost:8080/";
//loop through results of db query so items are displayed
while($row = mysql_fetch_array($result)){
// echo out contents of each row
echo '<tr>';
echo '<tr>';
echo '<td>'.$row["Product_ID"].'</td>';
echo '<td>'.$row["Brand"].'</td>';
echo '<td>'.$row["Description"].'</td>';
echo '<td>'.$row["Price"].'</td>';
echo '<td>'.'<img src="'.$img_url.$row['image'].'" /></td>';
echo '<td>'.'<a href = "?Add To List">Add To List</a></td>';
echo '</tr';
echo '</tr';
$add_to_list = "INSERT INTO andrew VALUES('".$row["Product_ID"]."', '".$row["Brand"]."', '".$row["Description"]."', '".$row["Price"]."', '".$row["image"]."')";
if(isset($_POST['Add To List'])){
mysql_query($add_to_list);
}
//close table
echo "</table>";
?>