echo "<br><table><tr>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
if ($j == 2) echo '<tr>';
echo '<td width="50%" valign="top"><strong>' . $row['name'] .
'</strong><br><strong>Price:</strong> £' . $row['price'] .
'<br><strong>Stock:</strong> ' . $row['stock'] . ' units' .
'<br><img src="upload/' . $row['imgName'] .
'" width="100em" height="100em" /><br><br>' . $row['descr'] .
'<br><a href="added.php?id="' . $row['P_id'] . '">Add to Cart</a></td>';
$j++;
}
有问题的元素是
$行[&#39; P_ID&#39;]
关于P_id的背景信息:
修改
根据要求:)
$query = "SELECT * FROM products WHERE prodGroup='$prodGroups[0]'"; // GET PRODUCTS FROM FIRST PRODUCT GROUP
$result = mysql_query($query);
修改
$query = "CREATE TABLE products (
P_id INT AUTO_INCREMENT NOT NULL KEY,
name VARCHAR(128) NOT NULL,
price DECIMAL(5,2) UNSIGNED NOT NULL,
descr TEXT,
imgName VARCHAR(50),
stock INT UNSIGNED NOT NULL DEFAULT '0',
prodGroup VARCHAR(128) NOT NULL
)";
答案 0 :(得分:1)
在id =之后删除“,然后再试一次。
<a href="added.php?id="' . $row['P_id'] . '">Add to Cart</a>
应该是
<a href="added.php?id=' . $row['P_id'] . '">Add to Cart</a>