有很多方法可以完成這項任務。但我會告訴你一個:
//store the variable
$title = $_POST['Title'];
$qty = $_POST['Qty'];
$price = $_POST['Price'];
//connect to database
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'rootpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn)
{
die('Could not connect: ' . mysql_error());
}
//sql syntax
$sql = 'INSERT INTO Bill (Title,Qty,Price,Total) VALUES (".$title.", ".$qty.", ".$price.", ".$qty * $price.")';
//select tabel
mysql_select_db('your_table_name');
//insert into tabel
$retval = mysql_query($sql, $conn);
if(! $retval)
{
die('Could not enter data: ' . mysql_error());
}
是的,我知道這一個。我只是好奇學習存儲過程的方法。沒有觸及編碼..希望你明白:) – user3234868
離開它,我明白了..謝謝你。 – user3234868