Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP Populate Drop Down Menu

  • 05-03-2008 5:27pm
    #1
    Registered Users, Registered Users 2 Posts: 357 ✭✭


    Hey

    I'm trying to populate a drop down box from a MySQL Database
    Can anyone see whats wrong with this code


    $query="SELECT rate FROM tariff_rate";
    $result=mysql_query($sql);
    
    $options="";
    
    echo $row['rate'];
    
    while ($row=mysql_fetch_array($result)) {
    $options = <option value=".$row['rate'].">"<php? echo ".$row['rate']."?>"</option>;
    }
    


Comments

  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Few syntax errors and missing tags in there.

    Needs to look like this:
    while ($row=mysql_fetch_array($result)) {
    $options = <option value="<?php echo ".$row['rate']."?>"><?php echo ".$row['rate']."?></option>;
    }
    

    See the difference? :)


  • Registered Users, Registered Users 2 Posts: 357 ✭✭apoch632


    Yeah.

    Its now throwing this error
    Parse error: syntax error, unexpected '<' in blahblah on line 24


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    apoch632 wrote: »
    Yeah.

    Its now throwing this error
    Parse error: syntax error, unexpected '<' in blahblah on line 24
    And what is line 24?


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    D'oh, totally read the code wrong.

    Should look like this:
    while ($row=mysql_fetch_array($result)) {
    $options .= "<option value=\"".$row['rate']."\">".$row['rate']."</option>";
    }
    


Advertisement