[請益] 請問一下資料庫執行兩次的問題?
<?php
mysql_connect("localhost","****","*******");
mysql_select_db("class");
if(!@mysql_select_db("class"))die("資料庫選擇失敗!");
$sql_query="select `total` from `total`";
$result=mysql_query($sql_query);
while($row_result=mysql_fetch_assoc($result)){
$history=$row_result["total"];
$history=$history+$benefits;
}
echo $history;
if(isset($_POST["action"])&&($_POST["action"]=="save")){
$sql_query="update `total` SET `total`=".$history;
mysql_query($sql_query);
header("location: stock.php");
}
?>
請問一下?我現在要做一個功能就是先從資料庫裡抓一個total的值出來然後再把benefit
s的值加上去,然後再把加完的值$history存回到資料庫中,不知道這種情形要先關閉資
料庫然後再開,還是直接mysql_query就好?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 36.237.222.183
→
07/04 18:11, , 1F
07/04 18:11, 1F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章
4
18
6
15