Jump to content

Archived

This topic is now archived and is closed to further replies.

Alanmoss

Mysql syntax

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]

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.