Php 回显mysql\u num\u行的所有行

Php 回显mysql\u num\u行的所有行,php,Php,我有以下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);

我有以下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]+“您的问题解决方案如下 使用echo“;print_r($info);die;
或者使用for循环,您将获得所需的所有数据。

好吧,您只是在打印一个数据,所以请将其放入循环中。我建议:

$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
$str = '';
if($n>0)
{
    while ($info=mysql_fetch_assoc($q)) {
        $str .= $info['SMILES'] .'<';
    }
echo substr($str, 0, -1);
} else {
    echo "molecule not found";
}
$q=mysql\u query(“选择GeoAndEnergies中的SMILES,其中权重=”“$data.””)或die(mysql\u error());
$n=mysql\u num\u rows($q);//不是mysql\u fetch\u row,因为它不返回count,而是一个数组
$str='';
如果($n>0)
{
而($info=mysql\u fetch\u assoc($q)){

$str.=$info['SMILES'].使用
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;
$q=mysql\u query(“选择GeoAndEnergies中的SMILES,其中权重=”“$data.””)或die(mysql\u error());
$n=mysql\u num\u行($q);
如果($n>0)
{
$val='';
而($info=mysql\u fetch\u row($q))
{
如果($val!='')
$val.='<';
$val.=$info[0];
}
}
否则{
$val=“未找到分子”;
}
echo$val;

我想添加分隔符“是的,就像这个回声”;打印($info);死亡;添加分隔符”