-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?

1

2 Answers 2

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);
Sign up to request clarification or add additional context in comments.

2 Comments

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
@sadbeginner then you did something wrong. Read this : techonthenet.com/mysql/where.php
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'];
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.