-3

list table

  • id
  • name
  • illness
  • recipe
  • directions

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

I want to only get the rows

  • $row['recipe'];
  • $row['directions'];

if the value of illness column is equals to highblood. how do I do this?

  • This isn't an answer to your question, but you should *not* be using mysql_* today. Consider PDO. http://stackoverflow.com/questions/16859477/why-are-phps-mysql-functions-deprecated – Tom Mettam Apr 18 '16 at 15:46

2 Answers2

2

I suggest to make some search on google to learn MySQL if you can't do basic query like this.

mysql_query("SELECT * FROM list WHERE illness = '".$illness."'",$con);
poudigne
  • 1,694
  • 3
  • 17
  • 40
  • did this at first but It has the same effects with $list = mysql_query("SELECT * FROM list ",$con); because i still get the rows of recipe of other illness like Anemia – sad beginner Apr 18 '16 at 15:39
  • @sadbeginner then you did something wrong. Read this : http://www.techonthenet.com/mysql/where.php – poudigne Apr 18 '16 at 15:40
2

Select only required rows.

$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'];
}