kissfreaque Posted February 28, 2011 Share Posted February 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/229141-need-to-pull-exact-data/ Share on other sites More sharing options...
Muddy_Funster Posted February 28, 2011 Share Posted February 28, 2011 $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. Quote Link to comment https://forums.phpfreaks.com/topic/229141-need-to-pull-exact-data/#findComment-1180793 Share on other sites More sharing options...
kissfreaque Posted February 28, 2011 Author Share Posted February 28, 2011 to call each fish individually, can you do something like this? echo $row['fish'] WHERE 'fish' = 'Seabass'.' '; Quote Link to comment https://forums.phpfreaks.com/topic/229141-need-to-pull-exact-data/#findComment-1180801 Share on other sites More sharing options...
Muddy_Funster Posted February 28, 2011 Share Posted February 28, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/229141-need-to-pull-exact-data/#findComment-1180818 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.