Php 产品预订脚本

Php 产品预订脚本,php,mysql,sql-update,form-submit,Php,Mysql,Sql Update,Form Submit,我正在尝试编写一个脚本,为商店保留产品。它应该将数据发送到mysql数据库,然后返回“shop”中的值。守则如下:; 参观商店 <form action="reserveitems3.php" method="POST"> <?php // Connects to your Database mysql_connect("localhost", "dbname", "password") or die(mysql_error()) ; mysql_select_

我正在尝试编写一个脚本,为商店保留产品。它应该将数据发送到mysql数据库,然后返回“shop”中的值。守则如下:; 参观商店

<form action="reserveitems3.php" method="POST">
<?php 



// Connects to your Database 
 mysql_connect("localhost", "dbname", "password") or die(mysql_error()) ; 
 mysql_select_db("dbname") or die(mysql_error()) ; 

 //Retrieves data from MySQL 
 $data = mysql_query("SELECT * FROM products") or die(mysql_error()); 

//Puts it into an array 
while($info = mysql_fetch_array( $data )) { 



// render each dtabase result and wrap in a div
echo "<div class='product'>";
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>";
echo "<tr>
<td class='image'><img src=http://my-creativewebfusion.com/mysql_data/file/".$info['photo'] . "></td>
<td class='name'>".$info['name'] . "<br/><br/>".$info['desc'] . "</td>
<td class='phone'><input name='".$info['id']."' type='checkbox' value='yes' style='position:relative;float:right;right:50px;' class='checked' onclick='document.getElementById('other').innerHTML = 'Check Box = ' + this.checked;'/><br/><br/>
<div class='alignright'>Price:&nbsp;".$info['price'] . "</div>
<div class='alignright'>QTY:&nbsp;<input type='text' name='reserve' style='width:40px;'/></div>

<div class='alignright'> ";

$sum_total = $info['stock']  - $info['reserve'] ;


if ($sum_total == 0)
{
echo "<p style='color:red;'>Out of stock</p>";
}
        else
{


        echo "<p style='color:green;float:right;'>",($sum_total),"&nbsp;&nbsp;In stock</p>&nbsp;";
         echo "<p style='color:green;'>".$info['reserve']."&nbsp;Reserved</p>";

}

echo "</div></td></tr>";
echo "</table>";
echo "</div><input type='submit' value='Submit' />";
}
?> 

</form>


您正在尝试向数字中添加字符串($reserve括在引号中)。尝试删除更新查询中的引号,即:

mysql_query("UPDATE products SET reserve= reserve + $reserve WHERE id ='$id'");
改变


哪个错误?404? BSOD?内核恐慌?我尝试了上面的方法,谢谢你的回答,但基本上没有效果。我试图通过增加表单中的金额来更新数量,并将其发布到脚本中,以按此金额更新行。有什么想法吗?
mysql_query("UPDATE products SET reserve= reserve + $reserve WHERE id ='$id'");
mysql_query("UPDATE products SET reserve= reserve + '$reserve' WHERE id ='$id'");
mysql_query("UPDATE products SET reserve = reserve" . $reserve . " WHERE id ='$id'");