所以我試圖讓AA網店,基本上是不工作是執行查詢時買進點擊「買入」 button.The查詢:如何通過點擊PHP中的按鈕觸發一個SQL查詢?
$sql = mysql_query("INSERT INTO vehicles (model,owner) VALUES ('$vehid','$id')");
和按鈕
<form action=\"\" method=\"post\">
<input type=\"submit\" value=\"BUY\">
</form>
整個代碼:
<?php
$id = $_SESSION['SESS_MEMBER_ID'];
include ('config2.php');
$result = mysql_query("select * from shop_vehicule ORDER BY id DESC");
$result2 = mysql_query("select * from accounts where id = '$id'");
while($row = mysql_fetch_array($result2))
$credit = $row['credits'];
while($row = mysql_fetch_array($result)){
$name = $row['nume'];
$price = $row['pret'];
$left = $credit - $price;
$vehid = $row['vehid'];
echo "<p><center><b>$name</b> | $price </center>
<a href=\"#\" class=\"topopup\">More information about $name</a></p>
<div id=\"toPopup\">
<div class=\"close\"></div>
<span class=\"ecs_tooltip\">Press Esc to close <span class=\"arrow\"></span></span>
<div id=\"popup_content\"> <!--your content start-->
<p>
The $name costs $price, after you'll have $left !</p>
<form action=\"\" method=\"post\">
<input type=\"submit\" value=\"BUY\">
</form>
</div>
</div>
<div class=\"loader\"></div>
<div id=\"backgroundPopup\"></div>";
$sql = mysql_query("INSERT INTO vehicles (model,owner) VALUES ('$vehid','$id')");
}
mysql_close();
?>
你問不好的問題,並有可能失去你的問題 - 要求特權。 [您應該在發佈下一個之前閱讀此內容。](http://s.tk/onhold) – 2014-08-27 17:51:59
'mysql_query'是一個過時的界面,不應在新應用程序中使用,並且將在未來版本的PHP中刪除。像[PDO這樣的現代化替代品並不難學](http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/)。如果您是PHP的新手,像[PHP The Right Way](http://www.phptherightway.com/)這樣的指南可以幫助解釋最佳實踐。 – tadman 2014-08-27 18:12:03
你所提問題的種類表明缺乏基礎知識。你對PHP有什麼參考?一本好書或參考網站將大大緩解你的學習。 – tadman 2014-08-27 18:13:30