Jump to content

While Mysql result add if into the print


josephicon

Recommended Posts

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;	
}
}
?>		

  • 3 weeks later...

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.