我對PHP很新,我正在嘗試創建一個庫存數據庫。我一直在努力讓用戶輸入卡片ID,然後將其添加到廣告資源中並讓廣告資源更新。例如,有人可以輸入測試和2342,它會更新測試。這是我一直在努力,但沒有成功:使用PHP添加到MySQL數據庫
add.html
<body>
<form action="add.php" method="post">
Card ID: <input type="text" name="CardID" />
Amount to Add: <input type="text" name="Add" />
<input type="submit" />
</form>
</body>
</html>
add.php
<?php
$link = mysql_connect('host', 'username', 'password');
if (!$link){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tdm_inventory", $link);
$add = $_POST[Add]
mysql_query("UPDATE cardLists SET AmountLeft = '$add' WHERE cardID = 'Test'");
echo "test successful";
mysql_close($link);
?>
你可能想要現在更改你的用戶名和密碼.. – jasonbar 2010-03-22 20:36:19
我現在做了。糟糕的廢話 – shinjuo 2010-03-22 20:40:56