所以我试图让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