Reputation: 4296
I have a database table which looks like:
In my code i call all the results in a for loop like this:
<?php
require 'database/connect.php';
$pdores = $conn->query("SELECT * FROM excersises");
foreach($pdores as $row) {
echo "$row[2] ";
}
?>
This gives me all the results under the row named excersise. My problem is if i have an excersise with muscle_id 3 it will also display it. I only want to display the excersises with the muscle_id 1
So basically i want to display data on certain conditions, in this case when the muscle_id equals to 1.
Any idea how to do this?
Thanks so much in advance,
Kevin
Upvotes: 0
Views: 79
Reputation: 4007
I hope this is what you want:
<?php
require 'database/connect.php';
$muscle_id =1;
$pdores = $conn->query("SELECT * FROM excersises where muscle_id=$muscle_id");
foreach($pdores as $row) {
echo "$row[2] ";
}
?>
Upvotes: 1