大家好我用獲取數組來顯示我的成績創造了一些劇本,但現在我有問題,我將如何插入數據導致新表保存按鈕,將在我的本地主機表
保存數據---第1頁
<?php
while ($row = mysql_fetch_array($query)) {
echo "<tr>";
echo "<td><input type=\"text\" name=\"grouping\" value=\"".stripslashes('NINS_LEC')."\" /></td>";
echo "<td><input type=\"text\" name=\"InvoiceAccNum\" value=\"". stripslashes($row['InvoiceAccNum']) ."\" /> </td>";
echo "<td><input type=\"text\" name=\"AccountFirstName\" value=\"". stripslashes($row['AccountFirstName']) . "\" /></td>";
echo "<td><input type=\"text\" name=\"SubsidiaryCode\" value=\"". stripslashes($row['SubsidiaryCode']) ."\" /></td>";
echo "<td><input type=\"text\" name=\"HandlingCode\" value=\"" . stripslashes($row['HandlingCode']) . "\" /></td>";
echo "</tr>";
}
?>
</table>
<?echo "$num_rows Rows\n";?>
<? echo
"<form name='vw_ob_save' method='get'>
<fieldset>
<table width='680'><tr>
<td colspan='4' align='center'>
<input type='submit' name='btn_save' value='Save'>
</td></tr></table></fieldset></form>";
if(isset($_POST['btn_save'])){
include 'grouping.php';
if($query1>0){
msgalert("data save!");}
}?>
這一個是現在的工作,但是當我grouping.php頁是執行我只有1個數據在我的表保存。
grouping.php
<?php
session_start();
$username = "root";
$password = "";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "";
$selected = mysql_select_db("bsswebtool",$dbhandle)
or die("Could not select bsswebtool");
if(empty($_POST['form1']))
{
$grouping = $_POST['grouping'];
$InvoiceAccNum = $_POST['InvoiceAccNum'];
$AccountFirstName = $_POST['AccountFirstName'];
$SubsidiaryCode = $_POST['SubsidiaryCode'];
$HandlingCode = $_POST['HandlingCode'];
}
else
{
$grouping =null;
$InvoiceAccNum =null;
$AccountFirstName =null;
$SubsidiaryCode =null;
$HandlingCode =null;
}
$query1 = "INSERT INTO nins_lec (rid,grouping,InvoiceAccNum,AccountFirstName,SubsidiaryCode,HandlingCode)
values
('','$grouping','$InvoiceAccNum','$AccountFirstName','$SubsidiaryCode','$HandlingCode')";
mysql_query($query1);
?>
我希望影響到我的數據庫9行,但只有1列,建立在我的數據庫 例如數據檢查插入導致
Groupings InvoiceAccNum AccountFirstName SubsidiaryCode HandlingCode
NINS_LEC 0000000000 ana XXXX D
NINS_LEC 0000000000 tiana XXXX Q
NINS_LEC 0000000000 LOPEZ KARL CHU XXXX Q
NINS_LEC 0000000000 pepe XXXX Q
NINS_LEC 0000000000 SANTOS XXXX R
NINS_LEC 0000000000 WONG XXXX Q
NINS_LEC 0000000000 BERNALDEZ XXXX R
NINS_LEC 0000000000 PALICOS XXXX Q
NINS_LEC 0000000000 JOSE XXXX Q
9 Rows
的http://stackoverflow.com/questions/18910017/update-multiple-rows-at-once-in-php/18910109#18910109 – mavrosxristoforos
沒了這個人是不同的,我要救我的可能的複製導致我的數據庫,但我只有一個結果保存, – rochelle
它是如何不同,因爲你試圖對9個不同的值進行1 INSERT查詢,沒有它在一個循環? – mavrosxristoforos