从包含多个匹配记录的表中仅显示一条记录

时间:2014-01-24 09:48:36

标签: php mysql

只从数据库表中检索到一条记录,其中有四条记录与查询匹配。我想要检索Tno为c23,电子邮件为nancy@yahoo.com的列,有四条记录,但我只能检索一条

enter code here

<form name="form1" method="post"> 
<?php
$host="localhost"; // Host name 
$username="global"; // Mysql username 
$password="solutions"; // Mysql password 
$db_name="test"; // Database name 
$tbl_name="supactiv"; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
$Tno=$_POST['Tno'];
$Email=$_POST['Email'];
if(isset($_POST['Submit'])) {
$_SESSION['Tno']=$Tno;
$_SESSION['Email']=$Email;
}
$sql1="SELECT * FROM `supactiv` WHERE Tno='c23' AND Email='nancy@yahoo.com'";
$result1=mysql_query($sql1);
while($row=mysql_fetch_array($result1,MYSQL_ASSOC))
{
?>
<table border=1><tr><td><?php echo $row['Tno']; ?></td>
<td><?php echo $row['Email']; ?></td>
<td><?php echo $row['pdesc']; ?></td>
<td><?php echo $row['Activity']; ?></td></tr>
</table>
<?php
}
?>
<input type="text"  name="Tno" value="<?php echo $Tno ?>" /> 
<input type="text"  name="Email" /> 
<textarea name="pdesc"> </textarea> 
<textarea name="Activity"> </textarea> 
<input  type="submit" value="Submit" /> 
 </form>

0 个答案:

没有答案