default value for drop down menu

i use the following code to create a drop down menu with the default value set as 0


	$mysqli = new mysqli('localhost','root','******');

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

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



My problem now is that when i submit this data if i leave that dropdown as the default (0) the first time it submitted a 3, the second time a 2 and now it just submits 1.
This is very confusing as i cannot see where it is getting this data from.


MOD EDIT: Removed password

I’m not sure if mysqli is capable of producing an object like that, but I presume that’s something you’ve looked up. Are you using error_reporting(E_ALL) to display all issues? If so, you could try using print_r() to make sure your variables contain what you think they contain.

when i didnt set the default to zero and just had the drop down menu with the first value show as the first value in the database it worked fine i.e. it inputted the correct value but now i have added the extra line to set the default to zero it seems to have gone a bit strange.


What does your HTML output look like?

Sponsor our Newsletter | Privacy Policy | Terms of Service