Jump to content

default value for drop down menu


truck7758

Recommended Posts

i have created a dropdown menu using the following code

 

<?

	$mysqli = new mysqli('host','username','password');
	$mysqli->select_db('orders');

	$result = $mysqli->query("SELECT * FROM quotes");

	echo "<SELECT name='quoteid'>\n";
	while($row = $result->fetch_assoc()) {
		echo "<option value='{$row['quoteid']}'>{$row['quoteid']}</option>\n";	
	}
	echo "</select>\n";

	$result->close();

	?>

 

this works fine but what i need now is for the default value to be either blank or say something like please select and if nothing else is selected than for it to insert a blank value

 

Thanks,

Mike

Link to comment
https://forums.phpfreaks.com/topic/98135-default-value-for-drop-down-menu/
Share on other sites

:) :) :)

 

<?

	$mysqli = new mysqli('host','username','password');
	$mysqli->select_db('orders');

	$result = $mysqli->query("SELECT * FROM quotes");

	echo "<SELECT name='quoteid'>\n";
        echo "<option value=''>Select</option>\n";
	while($row = $result->fetch_assoc()) {
		echo "<option value='{$row['quoteid']}'>{$row['quoteid']}</option>\n";	
	}
	echo "</select>\n";

	$result->close();

	?>

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.