作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有以下 php
$q=mysql_query("select SMILES from GeoAndEnergies where Weight='".$data."' ") or die(mysql_error());
$n=mysql_num_rows($q); //not mysql_fetch_row, as that does not return count but an array
if($n>0)
{
$info=mysql_fetch_row($q);
echo $info[0];
}
else {
echo "molecule not find";
}
我不仅要回显 $info[0],还要回显 $info[0]+"<"+ $info[1] + "<".... + $info[n],那会是什么语法正确吗?
谢谢
最佳答案
使用while
循环获取所有行
$q=mysql_query("select SMILES from GeoAndEnergies where Weight='".$data."' ") or die(mysql_error());
$n=mysql_num_rows($q);
if($n>0)
{
$val='';
while($info=mysql_fetch_row($q))
{
if($val!='')
$val.=' < ';
$val.= $info[0];
}
}
else {
$val= "molecule not find";
}
echo $val;
关于php - 回显 mysql_num_rows 的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31179362/
我是一名优秀的程序员,十分优秀!