Jump to content

Mysql syntax


Alanmoss

Recommended Posts

I'am trying to populate a drop down list from my date base
The drop down list shows the correct number of entrys from the table
but they are blank on the drop down list.

What have I done wrong . I think its a simple syntax error but I just can't see it.

Help please.

Here's the code:
[code]
echo '<div align="center">
<form method="get" action="users_online.php">
<select name="type">
<option value="">Choose a Category:</option>
';

// Retrieve and display the available categories.
$query = 'SELECT * FROM currency ORDER BY currency_id';
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {

//this line is the problem

    echo '<option value="'.$row['exchange_rate'].'">'.$row['country_name'].'</option>';
}

// Complete the form.
echo '</select>
<input type="submit" name="submit" value="Go!">
</form>
</div>';
if(isset($_POST['type']))
    {
        $name = $_POST['type'];
echo'<p>'.$name.'</p>';
}[/code]
Link to comment
Share on other sites

try changing MYSQL_NUM to MYSQL_ASSOC

MYSQL_NUM returns an array like: [0] -> Hello [1] -> Hi
whereas MYSQL_ASSOC returns an array like: [Money] -> 12 [Tax] -> 17.5

you can refer to a MYSQL_ASSOC array with $array['tax'] which is what you seem to be using
Link to comment
Share on other sites

[!--quoteo(post=378067:date=May 29 2006, 02:12 PM:name=Randy)--][div class=\'quotetop\']QUOTE(Randy @ May 29 2006, 02:12 PM) [snapback]378067[/snapback][/div][div class=\'quotemain\'][!--quotec--]
try changing MYSQL_NUM to MYSQL_ASSOC

MYSQL_NUM returns an array like: [0] -> Hello [1] -> Hi
whereas MYSQL_ASSOC returns an array like: [Money] -> 12 [Tax] -> 17.5

you can refer to a MYSQL_ASSOC array with $array['tax'] which is what you seem to be using
[/quote]


Thanks Very Much it works.
Link to comment
Share on other sites

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.