|
|
|
เราจะ insert ข้อมูลลงฐานข้อมูลทีละหลายแถวยังไงครับ +++++++++ |
|
|
|
|
|
|
|
Code (PHP)
<?
$busstop1=$_POST['busstop1'];
$busstop2=$_POST['busstop2'];
$busstop3=$_POST['busstop3'];
$busstop4=$_POST['busstop4'];
$buslines=$_POST['$busline'];
for ($i=0;$i<count($busstop1)-1;$i++){
echo $buslines;
echo $busstop1[$i]."-".$busstop1[$i+1]."</br>";
echo $busstop2[$i]."</br>";
echo $busstop3[$i]."</br>";
echo $busstop4[$i]."</br>";
$sql[$i]="INSERT INTO tb_route(path_start, path_end, busline_id, distance, price,timeuse)
VALUES('".$busstop1[$i].",".$busstop1[$i+1].",".$busline.",".$busstop2[$i].",".$busstop3[$i].",".$busstop4[$i]."')";
if($query=mysql_query($sql[$i])) echo "successful";
else echo mysql_error()."<br>";
echo $sql[$i];
mysql_close($connect);
ผมต้องแก้ตรงไหนครับถึงจะถูกต้อง
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2010-10-06 00:49:48 |
By :
wisan191 |
View :
1411 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้ error ตรงไหนครับ
Code (PHP)
<?
$busstop1=$_POST['busstop1'];
$busstop2=$_POST['busstop2'];
$busstop3=$_POST['busstop3'];
$busstop4=$_POST['busstop4'];
$buslines=$_POST['$busline'];
for ($i=0;$i<count($busstop1)-1;$i++){
echo $buslines;
echo $busstop1[$i]."-".$busstop1[$i+1]."</br>";
echo $busstop2[$i]."</br>";
echo $busstop3[$i]."</br>";
echo $busstop4[$i]."</br>";
$sql="INSERT INTO tb_route(path_start, path_end, busline_id, distance, price,timeuse)
VALUES('".$busstop1[$i].",".$busstop1[$i+1].",".$busline.",".$busstop2[$i].",".$busstop3[$i].",".$busstop4[$i]."')";
mysql_query($sql) or die(mysql_error());
}
mysql_close($connect);
|
|
|
|
|
Date :
2010-10-06 10:18:22 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้มัน error หรือว่ายังไงค่ะ
|
|
|
|
|
Date :
2010-10-06 10:29:43 |
By :
poipypunch_9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|