SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2002
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What am i doing wrong?

    Hi I'm trying to create a select menu populated from a MySQL database, I can create the menu without any problems however when I try to add a IF statement for form validation purposes I keep getting T_String error.

    The code I'm using is as follows:

    PHP Code:
                $siteslist_query mysql_query("SELECT userid, sitename FROM sites WHERE approved=1");
                while (
    $siteslist mysql_fetch_array($siteslist_query)){
                       
                      if (
    $fields["siteid"] == '$siteslist['userid']'){
                  
    $selected 'selected';}
                  
                    
    $siteslist_echo .= '<option value"'.$siteslist['userid'].'">'.$siteslist['sitename'].'</option>';
        
    $siteslist_echo .= "\n";
        
            } 
    Can anyone take a look, and see what I'm doing wrong! I've played around with this bit of code for ages, and I fell like I'm going round in circles here

  2. #2
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $siteslist_query mysql_query("SELECT userid, sitename FROM sites WHERE approved=1");
                while (
    $siteslist mysql_fetch_array($siteslist_query)){
                       
                      if (
    $fields["siteid"] == $siteslist['userid']){
                  
    $selected 'selected';}
                  
                    
    $siteslist_echo .= '<option value"'.$siteslist['userid'].'">'.$siteslist['sitename'].'</option>';
        
    $siteslist_echo .= "\n";
        
            } 
    -- Jelena --

  3. #3
    SitePoint Member
    Join Date
    Sep 2002
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Worked a treat!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •