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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.