josephicon Posted February 16, 2007 Share Posted February 16, 2007 How do I within a WHILE then print "this if msql get-›result =1" "this if msql get-›result =2" "this if msql get-›result =1" Link to comment https://forums.phpfreaks.com/topic/38794-while-mysql-result-add-if-into-the-print/ Share on other sites More sharing options...
clarke78 Posted February 16, 2007 Share Posted February 16, 2007 You can use the switch statement in php to get certain statements to show up while performing your "while" loop. <?php $result = @mysql_query("SELECT * FROM table"); while($row = mysql_fetch_array($result)) { extract($row); switch ($row_name){ case "1": echo "Test 1"; break; case "2": echo "Test 2"; break; case "3": echo "Test 3"; break; } } ?> Link to comment https://forums.phpfreaks.com/topic/38794-while-mysql-result-add-if-into-the-print/#findComment-186501 Share on other sites More sharing options...
josephicon Posted March 6, 2007 Author Share Posted March 6, 2007 cheers thanks for that, so a If cannot be added into a while only a switch will work why exactly is this? Link to comment https://forums.phpfreaks.com/topic/38794-while-mysql-result-add-if-into-the-print/#findComment-200938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.