我得到了我的问题:D是关于$ _POST使用我的id无法在插入提交按钮中访问我插入隐藏在我的id的语句中
if(array_key_exists('myid',$_POST))
{
$query1="select * from patient where id=".$_POST['myid'];
$result1=mysql_query($query1);
echo $query1;
//var_dump($_POST['myid']);
$num2=Mysql_num_rows($result1);
$num3=Mysql_num_fields($result1);
//clinical file ro neshun mide
if($num2>0)
{
echo "<table border=2>";
for($i=0;$i<$num2;$i++)
{
$row=mysql_fetch_row($result1);
echo"<td>id</td><td>name</td><td>Lastname</td><td>Info</td><td>Sympthoms</td><td>Diagnosis</td>";
echo "<tr>";
for($j=0;$j<$num3;$j++)
{
echo"<td>$row[$j]</td>";
}
echo"</tr>";
}//for
echo"</table>";
$y=$_POST['myid'];
echo"<input type='hidden' name='negin' value='$y'>";
}//if
//showing pharmacies($_POST['ph']):
$query2="select * from pharmacies";
$result2=mysql_query($query2);
$nump=Mysql_num_rows($result2);
echo "Please Select a Pharmacy:<select ID=2 name='ph'>";
echo"<option >select please";
for($i=0;$i<$nump;$i++)
{
$row=mysql_fetch_row($result2);
echo"<option value=$row[1]>$row[1]";
echo"</option>";
}
echo"</SELECT>";
//showing drugs($_POST['dg']):
$query2="select * from pharmacy";
$result2=mysql_query($query2);
$nump=Mysql_num_rows($result2);
echo "Please Select Drug:<select ID=1 name='dg'>";
echo"<option >select please";
for($i=0;$i<$nump;$i++)
{
$row=mysql_fetch_row($result2);
echo"<option >$row[0]";
echo"</option>";
}
echo"</SELECT>";
echo"<b>Quantity:<input type='text' name='txt1'/>";
echo"<input type='submit' name='insert' value='insert this drug'/>";
}//ifmyid
if(array_key_exists('insert',$_POST))
{
echo "HELLO";
$negin=$_POST['negin'];
$qname="select * from pnt where id='$negin'";
$resname=mysql_query($qname);
$rown=mysql_fetch_row($resname);
echo $qname;
$na=$rown[1];
mysql_real_escape_string ($_POST['dg']);
mysql_real_escape_string ($_POST['txt1']);
mysql_real_escape_string ($_POST['ph']);
mysql_real_escape_string ($na);
$ins="insert into request(drug,qty,ph,situation,Doctor,userp)values('".$_POST['dg']."',".$_POST['txt1'].",'".$_POST['ph']."','underprocess','$uname','$na')";
echo $ins;
$rlt=mysql_query($ins);
//showing prescribe(table request)
$in="select * from request";
$rslt=mysql_query($in);
$num2=Mysql_num_rows($rslt);
$num3=Mysql_num_fields($rslt);
if($num2>0)
{
echo "<table border=2>";
echo"<td>id</td><td>drug</td><td>quantity</td><td>Doctor</td><td>explanation</td><td>pharmacy</td>";
for($i=0;$i<$num2;$i++)
{
$row=mysql_fetch_row($rslt);
echo "<tr>";
for($j=0;$j<$num3;$j++)
{
echo"<td>$row[$j]</td>";
}
echo"</tr>";
}//for
echo"</table>";
}//if$num2
}
答案 0 :(得分:0)
那是你的问题吗?我不确定 。如果那么简单!
<form name="xx" method="post">
<input type="submit" name="submit1" value="1" />
<input type="submit" name="submit2" value="2" />
</form>
第1步:在表单中添加具有相同名称的提交按钮。
if($_POST['submit1']=="1")
{
echo "form submited using first submit button";
}
if($_POST['submit2']=="2")
{
echo "form submited using second submit button";
}
第2步:获取不同部分的值。然后你可以为每个按钮做不同的工作
我认为这有帮助!