这是我的代码,使用表upload-data
,login
,paper
<!doctype html>
<html><head><meta charset="utf-8">
<title>Untitled Document</title>
</head><body>
<table border="3"><tr>
<th>Paper id</th>
<th>Paper Name</th>
<th>Reviewer Name</th>
<th>Paper Status</th>
</tr>
<?php $con=mysql_connect("localhost","root","");
mysql_select_db("conferencedb");
$qry="select paperid,papername from paper";
$rs=mysql_query($qry);
$qry1="select (`username`) from login where type='reviewer'";
$rs1=mysql_query($qry1);
while($row=mysql_fetch_row($rs))
{
if($row1=mysql_fetch_row($rs1))
{
echo "<tr>";
echo "<td>$row[0]</td>";
echo "<td>$row[1]</td>";
echo "<td><select name='type'>
只能从数据库中获取单个选项
<option value='$row1[0]'>$row1[0]</option>
</select></td>";
echo "<td>Pending</td>";
echo "</tr>";
}
}
?>
</table>
<input type="submit">
</body>
</html>
上面的代码正在运行,但它只从数据库中检索单行:$row1[0];
当前的输出窗口......我只是用标记区域
油漆
答案 0 :(得分:0)
mysql_fetch_row
一次提取1
行。
因此,如果您想获得多行,请使用
while($row1=mysql_fetch_row($rs1))
而不是
if($row1=mysql_fetch_row($rs1))
OR
编辑使用MYSQLi
如果你可以切换到MySQLi,你可以使用:
<?php $con=mysqli_connect("localhost","root","");
mysqli_select_db("conferencedb");
$qry="select paperid,papername from paper";
$rs=mysqli_query($qry);
$qry1="select (`username`) from login where type='reviewer'";
$rs1=mysqli_query($qry1);
while($row=mysqli_fetch_row($rs))
{
if($row1= mysqli_fetch_all ($rs1, MYSQLI_ASSOC))
{
echo "<tr>";
echo "<td>$row[0]</td>";
echo "<td>$row[1]</td>";
echo "<td><select name='type'>
mysqli_fetch_all
将获取SELECT
语句的所有结果行作为行数组。
编辑选择内的多个选项
另外
echo "<td><select name='type'>
<option value='$row1[0]'>$row1[0]</option>
</select></td>";
总会给你一个选项标签。
echo "<td><select name='type'>";
foreach($_row1 in $row1){
echo "<option value='$_row1[0]'>$_row1[0]</option>";
}
echo "</select></td>";
echo "<td>Pending</td>";
echo "</tr>";
}
}
?>
</table>
<input type="submit">
</body>
</html>
答案 1 :(得分:0)
并且,我不知道我们能做什么,如$ row [0] [&#39;列&#39;],$ row [1] [&#39;列&#39;]? ??
while($row=mysql_fetch_row($rs))
{
if($row1=mysql_fetch_row($rs1))
{
仅限
$count=0;
while($row=mysql_fetch_array($rs))
{
echo $paperid=mysql_result($rs,$count,'paperid');
echo $papername=mysql_result($rs,$count,'papername');
echo $username=mysql_result($rs1,$count,'username');
$count=$count+1;