|
|
|
ช่วยดูทีหลายชุดแล้วตาลายครับT T InsertMuntiple PHP+SQL ยังไม่ได้จ้า |
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","0000") or die("Error Connect to Database");
$objDB = mysql_select_db("ball");
for($i=1;$i<=$_POST["hdnLine"];$i++)
{
if($_POST["txtaddtableID$i"] != "")
{
$strSQL = "INSERT INTO addtable ";
$strSQL .="(addtableID,addtableHome,addtableAway,addtableHlt,addtableAlt,addtableBargain,addtableTime,addtableOutlook,addtableKickoff) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtaddtableID$i"]."','".$_POST["txtaddtableHome$i"]."','".$_POST["txtaddtableAway$i"]."', ";
$strSQL .="'".$_POST["txtaddtableHlt$i"]."','".$_POST["txtaddtableAlt$i"]."','".$_POST["txtaddtableBargain$i"]."', ";
$strSQL .="'".$_POST["txtaddtableTime$i"]."','".$_POST["txtaddtableOutlook$i"]."','".$_POST["txtaddtableKickoff$i"]."') ";
$objQuery = mysql_query($strSQL);
}
}
echo "Save Done. Click <a href='InsertTableShow.php'>here</a> to view.";
mysql_close($objConnect);
?>
</body>
</html>
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<?
/*** Connect ***/
$objConnect = mysql_connect("localhost","root","0000") or die("Error Connect to Database");
$objDB = mysql_select_db("ball");
mysql_query("SET NAMES UTF8");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
/*** List Record ***/
$strSQL = "SELECT * FROM addtable ORDER BY addtableID ASC";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form action="InsertTableCheck.php" name="frmAdd" method="post">
Select Line :
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<?
for($i=1;$i<=50;$i++)
{
if($_GET["Line"] == $i)
{
$sel = "selected";
}
else
{
$sel = "";
}
?>
<option value="<?=$_SERVER["PHP_SELF"];?>?Line=<?=$i;?>" <?=$sel;?>><?=$i;?></option>
<?
}
?>
</select>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="160"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="70"> <div align="center">Budget </div></th>
<th width="70"> <div align="center">Used </div></th>
</tr>
<?
$line = $_GET["Line"];
if($line == 0){$line=1;}
for($i=1;$i<=$line;$i++)
{
?>
<tr>
<td><select name="txtaddtableHlt<?=$i;?>" id="txtaddtableHlt<?=$i;?>">
<option value="yes">ต่อ</option>
<option value="no">-</option></td>
<td><select name="txtaddtableHome<?=$i;?>" id="txtaddtableHome<?=$i;?>">
<option value=""><-- เลือกทีมเจ้าบ้าน --></option>
<?
$strSQL = "SELECT * FROM addteam Where addteamLeague = 'England'";
$objQuery = mysql_query($strSQL);
mysql_query("SET NAMES utf8");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["addteamName"];?>"><?=$objResuut["addteamName"];?></option>
<?
}
?>
</select></td>
<td><select name="txtaddtableBargain<?=$i;?>" id="txtaddtableBargain<?=$i;?>">
<option selected="selected" value="yes">ราคา</option>
<option value="no">ปป</option>
</select></td>
<td><select name="txtaddtableAway<?=$i;?>" id="txtaddtableAway<?=$i;?>">
<option value=""><-- เลือกทีมเยือน --></option>
<?
$strSQL = "SELECT * FROM addteam Where addteamLeague = 'England'";
$objQuery = mysql_query($strSQL);
mysql_query("SET NAMES utf8");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["addteamName"];?>"><?=$objResuut["addteamName"];?></option>
<?
}
?>
</select></td>
<td><select name="txtaddtableAlt<?=$i;?>" id="txtaddtableAlt<?=$i;?>">
<option value="yes">ต่อ</option>
<option value="no">-</option>
</select></td>
<td><input type="text" size="5" name="txtaddtableTime<?=$i;?>" id="txtaddtableTime<?=$i;?>">
<td><input type="text" size="5" name="txtaddtableKickoff<?=$i;?>" id="txtaddtableKickoff<?=$i;?>">
<td><input type="text" size="10" name="txtaddtableOutlook<?=$i;?>" id="txtaddtableOutlook<?=$i;?>">
</tr>
<?
}
?>
</table>
<input type="submit" name="submit" value="submit">
<input type="hidden" name="hdnLine" value="<?=$i;?>">
</form>
</body>
</html>
ผลที่ได้คือ นิ่ง ในฐานข้่อมูลครับบ
Tag : PHP
|
ประวัติการแก้ไข 2011-10-01 01:41:24
|
|
|
|
|
Date :
2011-10-01 01:02:38 |
By :
romanztic |
View :
639 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root,0000 , ball
addtableID addtableHome addtableAway addtableHlt addtableAlt addtableBargain addtableTime addtableOutlook addtableKickoff
|
|
|
|
|
Date :
2011-10-01 01:03:55 |
By :
romanztic |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หาเจอแล้วครับ T T ขอบคุณทุกความคิดเห็น
|
|
|
|
|
Date :
2011-10-01 01:48:11 |
By :
romanztic |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|