default value for drop down menu

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

[code]<?

	$mysqli = new mysqli('localhost','root','******');
	$mysqli->select_db('orders');

	$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";

	$result->close();

	?>[/code]

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.

Thanks,
Mike

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.

Thanks

What does your HTML output look like?

Sponsor our Newsletter | Privacy Policy | Terms of Service