0

我有以下脚本来打印一个文本区域和一些文本。加载页面时,即使 while 条件为真,textarea 也不会出现。可能是什么问题呢?

$seq_query = "SELECT * FROM `mcsm`.`conseq_human` WHERE `MCSM_Id`='$mcsm_id';";
$seq_result = mysql_query($seq_query);

print '<table border="0" align="left" style="margin-left:207px"><tr><th align="left">Conserved sequence</th></tr>';

if(!$conseq = mysql_fetch_array($seq_result))
{
    print "<tr><td><p>Not sufficient information yet.</p></td></tr></table>";
}
else
{
    while($conseq = mysql_fetch_array($seq_result))
    {
        print "<tr><td><textarea name='seq_textarea' cols='100' rows=''>".$conseq['ConSequence']."</textarea></td></tr>
        <tr><td>Based on MSA of ".$conseq['MSA_No_of_Seq']." sequences from <a href='results1.php?category=".$conseq['FamilyName']."' target='_self'>".$conseq['FamilyName']."</a> family.</td></tr></table>";
    }
}
4

2 回答 2

4

尝试这个

$seq_query = "SELECT * FROM `mcsm`.`conseq_human` WHERE `MCSM_Id`='$mcsm_id';";
$seq_result = mysql_query($seq_query);
print '<table border="0" align="left" style="margin-left:207px"><tr><th align="left">Conserved sequence</th></tr>';
if(mysql_num_rows($seq_result)>0)
{
    while($conseq = mysql_fetch_array($seq_result))
   {
    print "<tr><td><textarea name='seq_textarea' cols='100'        rows=''>".$conseq['ConSequence']."</textarea></td></tr>
    <tr><td>Based on MSA of ".$conseq['MSA_No_of_Seq']." sequences from <a href='results1.php?category=".$conseq['FamilyName']."' target='_self'>".$conseq['FamilyName']."</a> family.</td></tr></table>";
   }
}
else{
print "<tr><td><p>Not sufficient information yet.</p></td></tr></table>";
}
于 2013-04-20T09:23:18.363 回答
0

您正在</table>为每次while迭代打印。试试这个:

$seq_query = "SELECT * FROM `mcsm`.`conseq_human` WHERE `MCSM_Id`='$mcsm_id';";
$seq_result = mysql_query($seq_query);
if (!$seq_result) {
    die('Invalid query: ' . mysql_error());
}
else{
    print '<table border="0" align="left" style="margin-left:207px"><tr><th align="left">Conserved sequence</th></tr>';
    if(mysql_num_rows($seq_result)==0)
    {
        print "<tr><td><p>Not sufficient information yet.</p></td></tr></table>";
    }
    else
    {
        while($conseq = mysql_fetch_array($seq_result))
        {
            print "<tr><td><textarea name='seq_textarea' cols='100' rows=''>".$conseq['ConSequence']."</textarea></td></tr>
                   <tr><td>Based on MSA of ".$conseq['MSA_No_of_Seq']." sequences from <a href='results1.php?category=".$conseq['FamilyName']."' target='_self'>".$conseq['FamilyName']."</a> family.</td></tr>";
        }
        echo '</table>';
    }
}
于 2013-04-20T10:18:34.467 回答