本文介绍了提交按钮将不会一键显示结果,而会在第二次单击时显示结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我单击更新按钮时,它不会更新表格,但是当我再次单击它时,它将被更新,我该如何纠正它?
When I click the update button it will not update the table but when i Click it again it will be updated how can I correct it?
<html>
<head>
<title>pharmacy</title>
<form method="post">
<?php
session_start();
$connection=Mysql_connect('localhost','admin','123');
Mysql_select_db('db',$connection);
$pname=$_SESSION['s1'];
$query="select * from request where ph='$pname'";
if(array_key_exists('rqlist',$_POST))
{
if(!$connection)
{
echo 'connection is invalid';
}
else
{
$result=mysql_query($query);
if($result )
{
$num=Mysql_num_rows($result);
$num1=Mysql_num_fields($result);
echo $num;
if($num>0)
{
echo "<table border=2> Table Request".$_SESSION['s1'];
echo"<tr>
<td>Id</td><td>Drug</td><td>Quantity</td><td>Doctor</td><td> </td><td>pharmacy</td><td>name</td><td>lastname</td><td>Situation</td>
</tr>";
for($i=0;$i<$num;$i++)
{
$row=mysql_fetch_row($result);
echo "<tr>";
for($j=0;$j<$num1;$j++)
{
echo"<td>$row[$j]</td>";
}
echo"<td><input type='Checkbox' name='p[$i]' value='on' unchecked /> </td>";
echo"</tr>";
}
}
}
}//else
}//array
if(array_key_exists('update',$_POST)){
$result=mysql_query($query);
$qut="select qun from $pname";
$rt=mysql_query($qut);
if($result && $rt)
{
$num=Mysql_num_rows($result);
$num1=Mysql_num_fields($result);
//num2=Mysql_num_rows($rt);
if($num>0)
{
echo "<table border=2> Table Request".$_SESSION['s1'];
echo"<tr>
<td>Id</td><td>Drug</td><td>Quantity</td><td>Doctor</td><td></td><td>pharmacy</td><td></td><td>Situation</td>
</tr>";
for($i=0;$i<$num;$i++)
{
$row=mysql_fetch_row($result);
$row2=mysql_fetch_row($rt);
$dr[$i]=$row[1];
$qu[$i]=$row[2];
$st[$i]=$row[7];
$qun[$i]=$row2[0];
$query8="select * from $pname where name='$dr[$i]' and qun>$qu[$i] ";
$result8=mysql_query($query8);
$num8=Mysql_num_rows($result8);
if($num8!=0)
{
if($row[5]!='ready' && $row[5]!='transfer from $pname')
{
$query9="update request set situation='ready' where drug='$dr[$i]' ";
$qu="update $pname set qun=$qun[$i]-$qu[$i] where name='$dr[$i]' ";
$result9=mysql_query($query9);
$resultqu=mysql_query($qu);
echo $qu;
}
}
else{
if($row[5]!='ready'&&$row[5]!='transfer from $pname')
{
$query10="update request set situation='transfer from $pname' where drug='$dr[$i]' ";
$result10=mysql_query($query10);
}
}
echo "<tr>";
for($j=0;$j<$num1;$j++)
{
echo"<td>$row[$j]</td>";
}
echo"<td><input type='Checkbox' name='p[$i]' value='on' unchecked /></td>";
echo"</tr>";
}//for$i
echo"</table>";
}//if num
}
}
?>
<input type="submit" name="rqlist" value="Request list"/>
<input type="submit" name="update" value="Update the list"/>
</form>
</head>
</html>
推荐答案
尝试取出请求列表按钮以查看是否有任何更改
Try taking out the request list button to see it if anything changes
这篇关于提交按钮将不会一键显示结果,而会在第二次单击时显示结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!