Jump to content

Drop Box SQL Populate Initially Blank


grantf

Recommended Posts

Hi, i have a drop box in a form that is populated using a SQL query. It works well however i would like to have it so that when the page is initially loaded the drop box is blank, and not have the first entry pre-loaded. I havent been able to do this using the HTML/PHP code so my current (messy) work around is having a blank SQL record and it makes it seem as though the first record is empty.. how to write this line to accomplish this and do away with the dodgy SQL record??

 

<?php
$link = mysql_connect( $myServer, $myUser, $myPass );
mysql_select_db( $myDB, $link );
$init=mysql_init("STOREDPROCEDURE", $link);
$result = mysql_exec($init);
?>

<select name="VALUE" id="VALUE"> <?php while ($row = mysql_fetch_object($result)) { echo "<option value='" . $row->name . "'>" . $row->name . "</option>"; } ?>
</select>

Link to comment
https://forums.phpfreaks.com/topic/96888-drop-box-sql-populate-initially-blank/
Share on other sites

<?php
$link = mysql_connect( $myServer, $myUser, $myPass );
mysql_select_db( $myDB, $link );
$init=mysql_init("STOREDPROCEDURE", $link);
$result = mysql_exec($init);
?>

<select name="SELECT" id="SELECT">
<option selected value='anything you like'></option>
<?php while ($row = mysql_fetch_object($result)) { echo "<option value='" . $row->name . "'>" . $row->name . "</option>"; } ?>
</select>

 

How about that?

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.