-3
這個代碼是用於顯示數據和更新數據。當查詢字符串設置好的文本框appersand提交按鈕也會出現頁面沒有提交
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<from action="category_listing.php" method="post">
<table border="5" width="250">
<?php
$queryy="select COUNT(*) from category"; //count rows
$results= mysqli_query($link, $queryy);
while ($res= mysqli_fetch_array($results))
{$total_rows=$res[0];}
$offset=$total_rows-1;
$qry="select ID from category LIMIT $offset,1";
$res= mysqli_query($link, $qry);
while ($res2= mysqli_fetch_array($res))
{
$lastvalue=$res2[0];
}
$query="select * from category";
$result= mysqli_query($link, $query);
while ($r= mysqli_fetch_array($result))
{
if(isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) && ($_REQUEST['id']>=0) && $_REQUEST['id']<=$lastvalue)
{
$id=$_REQUEST['id'];
if($r[0]==$id)
{
$name=$r[1];
echo '<tr><td>';
echo 'Name';
echo '</td>';
echo '<td><input type=text value="'.$r[1].'"></td></tr>';
echo '<tr><td colspan="2">';
echo '<input type="submit" name="btnupdate" value="Update">';
echo '<input type="submit" value="Cancel">';
echo '</td></tr>';
}
}
else
{
static $var=1;
if($var==1){echo '<tr><th>ID</th><th>Name</th> <th>Action</th></tr>';} //headers of category
echo "<tr><td>$r[0]</td><td>$r[1]</td>";
echo "<td><a href='category_listing.php?id=$r[0]'>Edit</a></td></tr>";
$var++;
}
}
?>
</table>
<input type="hidden" name="hidden" value="<?php if(isset($id)) echo $id;?>"/>
</from>
</body>
</html>
我只設置查詢字符串。當它被設置在URL中時。文本框出現,按下提交後,頁面不提交。
'from'和'/ from'應'form'和'/ form' – Stefan 2015-02-08 18:49:06