|
 |
|
อยากเพิ่มข้อมูลหลายๆข้อมูล ที่หน้าแสดงผลข้อมูลนี้เลย ทำไงค่ะ |
|
 |
|
|
 |
 |
|
ลองปรับมาใช้แล้วค่ะ แต่ข้อมูลไม่เข้า DB ผิดตรงไหนค่ะ
Code (PHP)
<form action="tea_sc_CD2.php" method="post" enctype="multipart/form-data" name="checkForm" id="checkForm" onsubmit="return check()">
<? $objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("db_intern");
// Search By Name or Email
$strSQL = "SELECT * FROM student WHERE (stud_id LIKE '%".$_GET["txtKeyword"]."%' or stud_name LIKE '%".$_GET["txtKeyword"]."%' ) and student.tea_id='".$_SESSION['id']."'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 10; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"]){
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page){
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0){
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by stud_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="535" border="1">
<tr bgcolor="#00CC00">
<th width="62"> <div align="center">ลำดับ</div></th>
<th width="112"> <div align="center">รหัสนักศึกษา</div></th>
<th width="205"> <div align="center">ชื่อ-สกุล</div></th>
<th width="128">กรอกคะแนนซีดี</th>
</tr>
<? $i=1;
$color = array("#EEEEEE","#F5F5F5");
while($objResult = mysql_fetch_array($objQuery)){
?>
<tr bgcolor="<?=$color[($i%2)]?>">
<td align="center"><?=$i++;?></td>
<td align="center"><?=$objResult["stud_id"];?></td>
<td><?=$objResult["stud_title"];?>
<?=$objResult["stud_name"];?>
<?=$objResult["stud_sname"];?></td>
<td align="center"><input name="cd_score<?=$i;?>" type="text" id="cd_score<?=$i;?>" size="5" /></td>
</tr>
<?
}
?>
</table>
<input name="stud_id<?=$i;?>" type="hidden" id="stud_id<?=$i;?>"/>
<input type="submit" name="submit" value="submit">
<input type="hidden" name="hdnLine" value="<?=$i;?>">
</form>
นี้คือหน้า save คะ
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("db_intern");
for($i=1;$i<=$_POST["hdnLine"];$i++)
{
if($_POST["CD_id$i"] != "")
{
$strSQL = "INSERT INTO sc_cd ";
$strSQL .="(cd_score,stud_id) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["cd_score$i"]."','".$_POST["stud_id$i"]."') ";
$objQuery = mysql_query($strSQL);
}
}
if($objQuery){
echo "กรอกคะแนนสำเร็จแล้ว<br>";
echo "<img src='images/loading.gif'>";
echo "<script>setTimeout(\"location='tea_sc_CD.php'\",1000);</script>";
}else{
echo "Error Save [".$strSQL."]";
echo "<br>การเพิ่มข้อมูลล้มเหลว<br>";
echo "<script>setTimeout(\"location='tea_sc_CD.php'\",1000);</script>";
}
mysql_close($objConnect);
?>
|
ประวัติการแก้ไข 2013-07-20 13:26:03
 |
 |
 |
 |
Date :
2013-07-20 13:25:30 |
By :
LaiLA |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หน้าแบบฟอร์ม
input ในบรรทัดที่ 57 ต้องย้ายไปอยู่ใน <td>....</td> ของบรรทัด 47 ให้ value="<?=$objResult["stud_id"];?"
หน้าบันทึก
บรรทัดที่ 7 if($_POST["CD_id$i"] != "") ให้เปลี่ยนเป็น if($_POST["stud_id$i"] != "")
|
 |
 |
 |
 |
Date :
2013-07-20 15:16:44 |
By :
{Cyberman} |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้แล้ว แต่ยังไม่ได้เหมือนเดิมเลยค่ะ  
Code (PHP)
<form action="tea_sc_CD2.php" method="post" enctype="multipart/form-data" name="checkForm" id="checkForm" onsubmit="return check()">
<? $objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("db_intern");
// Search By Name or Email
$strSQL = "SELECT * FROM student WHERE (stud_id LIKE '%".$_GET["txtKeyword"]."%' or stud_name LIKE '%".$_GET["txtKeyword"]."%' ) and student.tea_id='".$_SESSION['id']."'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 10; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"]){
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page){
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0){
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strSQL .=" order by stud_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="535" border="0">
<tr bgcolor="#00CC00">
<th width="62"> <div align="center">ลำดับ</div></th>
<th width="112"> <div align="center">รหัสนักศึกษา</div></th>
<th width="205"> <div align="center">ชื่อ-สกุล</div></th>
<th width="128">กรอกคะแนนซีดี</th>
</tr>
<? $i=1;
$color = array("#EEEEEE","#F5F5F5");
while($objResult = mysql_fetch_array($objQuery)){
?>
<tr bgcolor="<?=$color[($i%2)]?>">
<td align="center"><?=$i++;?></td>
<td align="center">
<input name="stud_id<?=$i;?>" type="text" id="stud_id<?=$i;?>" value="<?=$objResult["stud_id"];?>" size="9"/></td>
<td><?=$objResult["stud_title"];?>
<?=$objResult["stud_name"];?>
<?=$objResult["stud_sname"];?></td>
<td align="center"><input name="cd_score<?=$i;?>" type="text" id="cd_score<?=$i;?>" size="5" />
</td>
</tr>
<?
}
?>
<td> <input name="stud_id<?=$i;?>" type="hidden" id="stud_id<?=$i;?>"/>
<input type="submit" name="submit" value="submit">
<input type="hidden" name="hdnLine" value="<?=$i;?>"></td>
</table>
</form>
หน้า save ค่ะ
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("db_intern");
for($i=1;$i<=$_POST["hdnLine"];$i++)
{
if($_POST["stud_id$i"] != "")
{
$strSQL = "INSERT INTO sc_cd ";
$strSQL .="(cd_score,stud_id) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["cd_score$i"]."','".$_POST["stud_id$i"]."') ";
$objQuery = mysql_query($strSQL);
}
}
if($objQuery){
echo "กรอกคะแนนสำเร็จแล้ว<br>";
echo "<img src='images/loading.gif'>";
echo "<script>setTimeout(\"location='tea_sc_CD.php'\",1000);</script>";
}else{
echo "Error Save [".$strSQL."]";
echo "<br>การเพิ่มข้อมูลล้มเหลว<br>";
echo "<script>setTimeout(\"location='tea_sc_CD.php'\",1000);</script>";
}
mysql_close($objConnect);
?>
|
ประวัติการแก้ไข 2013-07-20 15:52:44 2013-07-20 15:53:40 2013-07-20 15:57:21
 |
 |
 |
 |
Date :
2013-07-20 15:50:52 |
By :
LaiLA |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หน้าแบบฟอร์ม บรรทัดที่ 59 input ตัวนี้ย้ายไปแล้ว ต้องไม่อยู่บรรทัดนี้นะครับ ลบออกด้วย
|
 |
 |
 |
 |
Date :
2013-07-20 16:13:58 |
By :
{Cyberman} |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าให้ บรรทัดที่ 59 input ย้ายไปอยู่ใน loop ก้อจะมีปุ่ม submit อยู่หลายปุ่มซิค่ะ
อยากให้มีแค่ปุ่มเดียว submit ครั้งเดียวทั้งฟอร์ม ค่ะ
|
ประวัติการแก้ไข 2013-07-21 11:26:56
 |
 |
 |
 |
Date :
2013-07-21 11:26:21 |
By :
LaiLA |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|