|
 |
|
ช่วยหน่อยอ่ะครับ เกี่ยวกับการinsert ด้วย check box |
|
 |
|
|
 |
 |
|
ผมอยากให้เวลาเลือก check box จากตารางเก่าแล้ว ข้อมูลต่างๆ จะไป insert เข้าไปยังอีกตารางอ่ะครับ
มันติดปัญหาตรงที่ เวลาตรงผมติกถูกแล้ว est_id จากตารางเก่า เข้าไปยังตารางใหม่ ฟิวส์เดียวครับ ฟิวส์อื่นไม่ไปอ่ะครับขอคำปรึกษาหน่อยนะ
Sample8.php
<form name="form1" method="post" action="sample9.php">
<?
$host="localhost";
$username="root";
$pass_word="root";
$db="project";
$tb="establishment1";
mysql_connect( $host,$username,$pass_word) or die (" ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die(" เลือกฐานข้อมูลไม่ได้") ;
$sql="Select * From $tb";
$db_query=mysql_db_query($db,$sql);
$num_rows=mysql_num_rows($db_query); /* นับ Reccord ที่พบ */
?>
เลือกรายการที่จะลบ
<table width="24%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td width="24%"> รหัสสี </td>
<td width="52%"> รายละเอียดสี </td>
<td width="24%"> เลือก </td>
</tr>
</table>
<?
$a=0;
while($a < $num_rows)
{
$result = mysql_fetch_array($db_query);
$est_id=$result[est_id];
$est_name=$result[est_name];
$address=$result[address];
$manager=$result[manager];
$cont_with=$result[cont_with];
$telephone=$result[telephone];
$fax=$result[fax];
$stu_branch=$result[stu_branch];
$character=$result[character];
$position=$result[position];
$choose=$result[choose];
$welfare=$result[welfare];
$note=$result[note];
?>
<table width="100%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td width="50%">
<?echo $est_id;?>
</td>
<td width="100%">
<?echo $est_name;?>
</td>
<td width="100%">
<?echo $address;?>
</td>
<td width="50%">
<?echo $telephone;?>
</td>
<td width="24%">
<input type="checkbox" name="array[]" value="<?echo "$est_id"; ?>">
</td>
</tr>
</table>
<?
$a++;
}
?>
<br>
<input type="submit" name="Submit" value=" เพิ่ม" >
Sample9.php
<?
$host="localhost";
$username="root";
$pass_word="root";
$db="project";
mysql_connect( $host,$username,$pass_word) or die (" ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die(" เลือกฐานข้อมูลไม่ได้") ;
for ($i=0;$i<count($array);$i++) {
$est_id = $array[$i];
$sql = "INSERT INTO establishment2
VALUES('$est_id','$est_name','$address','$manager','$cont_with', '$telephone','$fax','$stu_branch','$character','$position', '$choose','$welfare','$note')";
$db_query=mysql_db_query($db,$sql);
header('location:sample8.php');
}
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-02-04 09:59:21 |
By :
sanits |
View :
1016 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็เอาข้อมูลจากตารางเก่ามาด้วยสิครับ
|
 |
 |
 |
 |
Date :
2009-02-04 12:32:27 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอามายังไงหรอครับ
|
 |
 |
 |
 |
Date :
2009-02-04 14:42:26 |
By :
sanits |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|