再次编辑:新修订版
所以我已经纠正了我的表格中缺少标签,我已经在我的表单中添加了 id,我已经为每个表单添加了一个隐藏字段,其值也与表单 id 相同(如建议的那样)
我试图修改我的原始 if isset 以包含表单 ID,但这就是我遇到的问题。
如前所述,这是页面创建的 HTML:
<br><table border=1><tr><th>customer</th><th>product</th><th>employee</th><th>return_date</th><th>complete</th></tr><br><tr><td>marne1</td><td>basketball</td><td>user</td><td>01-10-12</td><td> <FORM id="1" method ="post" action ="g.php">
<input type='hidden' name='x' value='1'>
<Input type = 'Radio' Name ='ir' value= '47'> 47 <input type="submit" name="return"/>
</FORM>
</td></tr><br><tr><td>marne1</td><td>basketball</td><td>user</td><td>01-10-12</td><td> <FORM id="2" method ="post" action ="g.php">
<input type='hidden' name='x' value='2'>
<Input type = 'Radio' Name ='ir' value= '48'> 48 <input type="submit" name="return"/>
</FORM>
</td></tr><br><tr><td>marne1</td><td>basketball</td><td>user</td><td>02-10-12</td><td> <FORM id="3" method ="post" action ="g.php">
<input type='hidden' name='x' value='3'>
<Input type = 'Radio' Name ='ir' value= '49'> 49 <input type="submit" name="return"/>
</FORM>
</td></tr><br><tr><td>marne1</td><td>basketball</td><td>user</td><td>29-09-12</td><td> <FORM id="4" method ="post" action ="g.php">
<input type='hidden' name='x' value='4'>
<Input type = 'Radio' Name ='ir' value= '50'> 50 <input type="submit" name="return"/>
</FORM>
</td></tr><br><tr><td>marne1</td><td>basketball</td><td>user</td><td>01-10-12</td><td> <FORM id="5" method ="post" action ="g.php">
<input type='hidden' name='x' value='5'>
<Input type = 'Radio' Name ='ir' value= '51'> 51 <input type="submit" name="return"/>
</FORM>
</td></tr><br><tr><td>marne1</td><td>basketball</td><td>user</td><td>01-10-12</td><td> <FORM id="6" method ="post" action ="g.php">
<input type='hidden' name='x' value='6'>
<Input type = 'Radio' Name ='ir' value= '52'> 52 <input type="submit" name="return"/>
</FORM>
</td></tr><br><tr><td>marne1</td><td>basketball</td><td>user</td><td>02-10-12</td><td> <FORM id="7" method ="post" action ="g.php">
<input type='hidden' name='x' value='7'>
<Input type = 'Radio' Name ='ir' value= '60'> 60 <input type="submit" name="return"/>
</FORM>
</td></tr><br><tr><td>marne1</td><td>basketball</td><td>user</td><td>02-10-12</td><td> <FORM id="8" method ="post" action ="g.php">
<input type='hidden' name='x' value='8'>
<Input type = 'Radio' Name ='ir' value= '61'> 61 <input type="submit" name="return"/>
</FORM>
</td></tr><br></table>
<fieldset>
<legend>???</legend>
<form action="z.php" method="post">
Customer Name: <input type="text" name="ir" /> <br><br>
<input type="submit" name="return"/>
</form>
这是创建此 HTML 的 PHP 页面(使用我多次尝试的表单 id 测试):
<?php
$db_host = "localhost";
$db_username = "root";
$db_pass = "usbw";
$db_name = "test";
mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
mysql_select_db("$db_name") or die ("no database");
$result = mysql_query("SELECT * FROM rental WHERE customer = '$_POST[customer]' AND complete = '0' ") or die (mysql_error());
?>
<?php
echo '<br>';
echo '<table border=1>';
echo '<tr><th>customer</th><th>product</th><th>employee</th><th>return_date</th><th>complete</th></tr>';
echo "<br>";
$x=1;
while($row=mysql_fetch_array($result))
{
echo '<tr>';
echo '<td>';
echo $row ['customer'];
echo '</td><td>' ;
echo $row ['product'];
echo '</td><td>';
echo $row ['employee'];
echo '</td><td>';
echo $row ['return_date'];
echo '</td><td>';
$cur_return = $row ['rental_id'];
?>
<FORM id="<?php echo $x; ?>" method ="post" action ="g.php">
<input type='hidden' name='x' value='<?php echo $x; ?>'>
<Input type = 'Radio' Name ='ir' value= '<?php echo $cur_return ?>'> <?php echo $cur_return ?>
<input type="submit" name="return"/>
</FORM>
<?php
echo '</td></tr>';
echo '<br>';
$x++;
}
echo '</table>';
?>
<fieldset>
<legend>???</legend>
<form action="z.php" method="post">
Customer Name: <input type="text" name="ir" /> <br><br>
<input type="submit" name="return"/>
</form>
<?php
if (isset($_POST['return']))
{
if ($_POST['x']==1)
{
mysql_query("UPDATE rental SET complete = '1' WHERE rental_id = '$_POST[ir]'") or die (mysql_error());
}
}
?>
我真的很感谢你们提出的所有帮助,并为我花了这么多时间来解决这个问题表示歉意:)
富有的