Jump to content

Need to pull exact data


kissfreaque

Recommended Posts

I use to be good at this.... but I have not worked with this in several years.

 

I built a MySQL table with just to columns, fish and fresh. I need to pull them into a PHP page where I have a table set up with all the fish listed and a variable in front of each that will show either a checked or unchecked box to indicate that the fish is fresh that day.

 

I was thinking (in English) if '$Fish A' fresh = yes, then show checked.jpg - else {}

 

But I am drawing a complete blank on this. PLEASE HELP if you can. Much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/229141-need-to-pull-exact-data/
Share on other sites

$fish is english?  ;)

assuming your fresh column is populted by 'true' and 'false' then put this within the while loop of your database result call:

echo $row['fish'].' ';
if($row['fresh'] = 'true' {
echo '<img src="checked.jpg">';
}
echo'<br>

 

of cource, you'll probably want to format it into a table or - even better - tag it with some css, but that's more about the layout than the results.

I'm not sure what your asking with that.  To list each fish on it's own line, with the checked image next to the ones that have true in the fresh field, you would do:

$qry = 'SELECT fish, fresh FROM tableName';
$result = mysql_query($qry) or die ('Error querying the table : '.mysql_error());
while ($row = mysql_fetch_assoc($qry)){
echo $row['fish'].' ';
if($row['fresh'] = 'true' {
echo '<img src="checked.jpg">';
}
echo'<br>
}

 

To limit the results to only showing a specific fish, you would change the string assigned to $qry to use a WHERE condition.  Which are you looking to achieve?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.