Php 显示同一行的SQL

Php 显示同一行的SQL,php,mysql,sql,Php,Mysql,Sql,我试图获取数据库中的所有记录,并在表中逐行显示它们。它只会一次又一次地显示同一行。如何使表的每一行显示数据库中的下一个结果 <?php // Formulate query $logo = "SELECT logo from stores"; $cat = "SELECT cat from stores"; $commission = "SELECT commission from stores"; $link = "SELECT link from stores"; $name = "S

我试图获取数据库中的所有记录,并在表中逐行显示它们。它只会一次又一次地显示同一行。如何使表的每一行显示数据库中的下一个结果

<?php
// Formulate query
$logo = "SELECT logo from stores";
$cat = "SELECT cat from stores";
$commission = "SELECT commission from stores";
$link = "SELECT link from stores";
$name = "SELECT name from stores";
// Perform query
$result1 = mysql_query($logo) or die;
$result2 = mysql_query($cat) or die;
$result3 = mysql_query($commission) or die;
$result4 = mysql_query($link) or die;
$result5 = mysql_query($name) or die('Something went wrong');
//////////////////////////////////////
//////////////////////////////////////
do {
//////////////////////////////////////
$rlogo = mysql_fetch_assoc($result1);
$a = implode($rlogo);
//////////////////////////////////////
$rcat = mysql_fetch_assoc($result2);
$b = implode($rcat);
//////////////////////////////////////
$rcommission = mysql_fetch_assoc($result3);
$c = implode($rcommission);
//////////////////////////////////////
$rlink = mysql_fetch_assoc($result4);
$d = implode($rlink);
//////////////////////////////////////
$rname = mysql_fetch_assoc($result5);
$e = implode($rname);
//////////////////////////////////////
$x = $x + 1;
    } while ($x <= 1);
?>

如果您增加$x,但循环在达到1时结束。。。马上就结束了

   $x = $x + 1;
} while ($x <= 1);
$x=$x+1;
}而($x$value)
{
打印“$value.”;
}
//也可以按如下方式打印表格单元格:
//$row['logo']
//$row['cat']
//$row[“佣金”]
//$row['link']
//$row['name']
打印“”;
}
“印刷”;

另外,
mysql\uu
函数已经过时,很快将从PHP中删除,因此如果您正在学习,您应该学习
PDO
mysqli\u

请不要再使用
mysql\u*
函数,它们已被弃用。有关详细信息,请参阅。相反,您应该学习并使用或。如果您无法决定如果你选择PDO,。你必须循环获取结果。
while($rlogo=mysql\u fetch\u assoc($result1)){…}
当一个查询返回所有数据时,为什么要在表上运行五个查询?我不想得到另一列,所以我没有选择*,而是选择了我需要的特定列wanted@773看看我的答案,如果你有问题,请告诉我
 $query = "select logo, cat, commission, link, name  from stores";

 $result = mysql_query($query); 

 print "<table>";

 // table headers 
 print "<tr><th>logo</th>
            <th>cat</th>
            <th>comission</th>
            <th>link</th>
            <th>name</th></tr>";

 while($row = mysql_fetch_assoc($result))
 {
     print "<tr>"; 

     foreach ($row as $column => $value) 
     {
         print "<td>".$value."</td>";
     }

      // or you can print the table cells like this: 
      //  <td> $row['logo']      </td>
      //  <td> $row['cat']       </td>
      //  <td> $row['commission']</td>
      //  <td> $row['link']      </td>
      //  <td> $row['name']      </td>

     print "</tr>"; 
 }

 print "</table>;