This my code, using tables 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'>
only single option can fetch from the database
<option value='$row1[0]'>$row1[0]</option>
</select></td>";
echo "<td>Pending</td>";
echo "</tr>";
}
}
?>
</table>
<input type="submit">
</body>
</html>
above code is working ,but it retrieve only single row from the database: $row1[0];
The current output window...i just marked area using paint.
mysql_fetch_row
fetches 1
row at a time.
So if you want to get multiple rows use
while($row1=mysql_fetch_row($rs1))
instead of
if($row1=mysql_fetch_row($rs1))
OR
EDIT FOR USING MYSQLi
If you could switch to MySQLi you could use:
<?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
will fetch all the result rows of the SELECT
statement as an array of rows.
EDIT FOR MULTIPLE OPTIONS INSIDE SELECT
Also
echo "<td><select name='type'>
<option value='$row1[0]'>$row1[0]</option>
</select></td>";
will always give you one option tag.
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>
Can you try it? You are using two arrays in one loop. So I doing like this
And, I don't know whther we can do like this $row[0]['column'],$row[1]['column']???
while($row=mysql_fetch_row($rs))
{
if($row1=mysql_fetch_row($rs1))
{
to only
$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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.