Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.