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
https://forums.phpfreaks.com/topic/10700-mysql-syntax/
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
https://forums.phpfreaks.com/topic/10700-mysql-syntax/#findComment-39950
Share on other sites

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.