ทดสอบโค๊ดในหน้า .php ใช้งานได้ แต่พอเอาไปใช้งานจริงในหน้า .tpl.php ทำไมใช้งานไม่ได้แนะนำทีค๊ะ
ใช้งานไม่ได้นี้ มันใช้ไม่ได้แบบไหนครับ อธิบายหน่อยครับ ปัญหาที่ไม่ได้น่ะ
ลองเอาไปแทนดูครับ
Code (PHP)
############### Code
<?php
include("../connect.php");
$sql="SELECT * FROM test_mysql";
$result=mysql_query($sql);
// Count table rows
$count=mysql_num_rows($result);
?>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="">
<tr>
<td>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Lastname</strong></td>
<td align="center"><strong>Email</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center">
<? $id[]=$rows['id']; ?><? echo $rows['id']; ?>
<input type="hidden" name="h_id[]" value="<?=$rows[id]?>">
</td>
<td align="center">
<input name="name[]" type="text" id="name" value="<? echo $rows['name']; ?>">
</td>
<td align="center">
<input name="lastname[]" type="text" id="lastname" value="<? echo $rows['lastname']; ?>">
</td>
<td align="center">
<input name="email[]" type="text" id="email" value="<? echo $rows['email']; ?>">
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
if(isset($_POST[submit])){
$name=$_POST[name];
$lastname=$_POST[lastname];
$email=$_POST[email];
$id=$_POST[h_id];
for($i=0;$i<$count($id);$i++){
$sql1="UPDATE test_mysql SET name='$name[$i]', lastname='$lastname[$i]', email='$email[$i]' WHERE id=$id[$i]";
$result1=mysql_query($sql1);
}
}
if($result1){
header("location:update_content_hide.php");
}
mysql_close();
?>
ประวัติการแก้ไข 2013-03-10 20:45:10 2013-03-10 20:47:24
Date :
2013-03-10 19:51:17
By :
ฟูฟู
หนู copy โค๊ดนี้ไปวางแล้วแต่ก็ยังใช้ไม่ได้เลยค๊ะ
Code (PHP)
############### Code
<?php
include("../connect.php");
$sql="SELECT * FROM test_mysql";
$result=mysql_query($sql);
// Count table rows
$count=mysql_num_rows($result);
?>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="">
<tr>
<td>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Lastname</strong></td>
<td align="center"><strong>Email</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center">
<? $id[]=$rows['id']; ?><? echo $rows['id']; ?>
<input type="hidden" name="h_id[]" value="<?=$rows[id]?>">
</td>
<td align="center">
<input name="name[]" type="text" id="name" value="<? echo $rows['name']; ?>">
</td>
<td align="center">
<input name="lastname[]" type="text" id="lastname" value="<? echo $rows['lastname']; ?>">
</td>
<td align="center">
<input name="email[]" type="text" id="email" value="<? echo $rows['email']; ?>">
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
if(isset($_POST[submit])){
$name=$_POST[name];
$lastname=$_POST[lastname];
$email=$_POST[email];
$id=$_POST[h_id];
for($i=0;$i<$count($id);$i++){
$sql1="UPDATE test_mysql SET name='$name[$i]', lastname='$lastname[$i]', email='$email[$i]' WHERE id=$id[$i]";
$result1=mysql_query($sql1);
}
}
if($result1){
header("location:update_content_hide.php");
}
mysql_close();
?>
Date :
2013-03-11 13:34:40
By :
dferru
Load balance : Server 00