php while loop + where


php while loop + where

列表表

  • id
  • 名称
  • 疾病
  • 配方
  • 方向

    $illness = 'Highblood';
    $list = mysql_query("SELECT * FROM list ",$con);
    while($row=mysql_fetch_array($list, MYSQL_ASSOC)){
     $test[] = $row['recipe'];
     $test2[] = $row['directions'];
     }
    

我只想得到行

  • $row['recipe']
  • $row["方向"]

如果疾病列的值等于highblood。我该怎么做?

如果你不能做这样的基本查询,我建议你在谷歌上搜索一下MySQL。

mysql_query("SELECT * FROM list WHERE illness = '".$illness."'",$con);

只选择所需的行。

$list = mysql_query("SELECT recipe,directions FROM list WHERE illness='Highblood'",$con);
while($row=mysql_fetch_array($list, MYSQL_ASSOC)){
  $test[] = $row['recipe'];
  $test2[] = $row['directions'];
}