我有以下脚本来打印textarea和一些文本。加载页面时,即使条件为真,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>";
}
}
答案 0 :(得分: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>";
}
答案 1 :(得分: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>';
}
}