我正在创建一个票务系统,我需要一些帮助。下面的代码显示数据库记录,删除工作正常。然而,编辑工作并不起作用。
<?Php
require "config.php";
$page_name="currentout.php";
$start=$_GET['start'];
if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}
$eu = ($start - 0);
$limit = 10;
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
$nume = $dbo->query("select count(id) from receipt")->fetchColumn();
echo "<TABLE class='t1'>";
echo "<tr><th>ID</th><th>Name</th><th>Pass</th><th>Amount</th><th>Action</th></tr>";
$query=" SELECT * FROM receipt limit $eu, $limit ";
foreach ($dbo->query($query) as $row) {
@$m=$i%2;
@$i=$i+1;
echo "<tr class='r$m'><td>$row[id]</td><td>$row[name]</td><td>$row[phone_num]</td><td>$row[Amount]</td><td><a href='delete.php?id=$row[id]'>delete</a></td><td><a href='edit.php?id=$row[id]'>Edit</a></td></tr>";
}
echo "</table>";
if($nume > $limit ){
echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
if($back >=0) {
print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>";
}
echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";}
$l=$l+1;
}
echo "</td><td align='right' width='30%'>";
if($this1 < $nume) {
print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";}
echo "</td></tr></table>";
}
?>
以下代码为edit.php。它应该在点击时显示各个字段以允许编辑,但它不会选择任何字段。我错过了什么?
<?Php
require "config.php";
$sql = "SELECT FROM receipt WHERE ID= :ID";
$stmt = $dbo->prepare($sql);
$stmt->bindParam(':ID', $_GET['id'], PDO::PARAM_INT);
$stmt->execute();
?>
<form action="update.php" method="post" enctype="multipart/form-data">
<table align="center">
<tr>
<td> <label><strong>Full Names</strong></label></td>
<td> <input type='text' name='name' value=" <?php echo $row['name']; ?>" />
<input type="hidden" name="id" value="<?php echo $id; ?> " /> <br /></td>
</tr>
<tr>
<td><label><strong>ID/Passport No. </strong></label></td>
<td> <input type="text" name="pass" value="<?php echo $row['id_passno']; ?> " /><br /></td>
</tr>
<tr>
<td> <label><strong>Phone No. </strong></label></td>
<td><input type="text" name="phone" value="<?php echo $row['phone_num']; ?>" /> <br /></td>
</tr>
<tr>
<td> <label><strong>Amount (KShs.) </strong></label></td>
<td><input type="text" name="amount" value="<?php echo $row['Amount']; ?> "/> <br /></td>
</tr>
<tr>
<td>
<input type="reset" name="Reset" value="CANCEL" onClick="return confirm('Discard changes?');" />
<br></td>
<td>
<input type="submit" name="Submit2" value="SUBMIT" />
</td>
</tr>
</table>
</form>