再次编辑:新的修订版提交多一个PHP的形式提交按钮
所以我已经改正缺乏标签在我的表,我已经添加的ID在我的形式,我添加了一个隐藏字段给每个窗体。与表单ID相同的价值也如(建议)
我试图修改我原来如果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(我porly试图形式ID测试)PHP页面:
<?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());
}
}
?>
我真的很感谢你们所提供的所有帮助,并且对于我所得到的这个排序的时间表示歉意:)
Rich
你似乎没有问一个问题。 – andrewsi
是你的作业吗? ;-) –
对不起,我的问题是,它不工作......这是更多的声明,所以我想知道为什么它不工作:) – user1707055