Query Combo

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ddtpmyra
    Contributor
    • Jun 2008
    • 333

    Query Combo

    I have query combo but I notice It only save the first words. For instance,
    Commitee Members
    Commitee Officials

    It only pick the word 'Committee' and not the next word when I get the getPostValue. Why is it?

    Code:
    echo "<tr><td><b>OS Staff By</b></td>"; 
    $res=mysql_query("select OSName  from tblOSstaff"); 
    if(mysql_num_rows($res)==0){ 
    echo "there is no data in table.."; 
    } else { 
    echo "
    <td width='80%'><select name=\"staff_by\" id=\"staff_by\">"; 
       for($i=0;$i<mysql_num_rows($res);$i++) { 
       $row=mysql_fetch_assoc($res); 
       echo"<option value=$row[OSName]"; 
       if($Var==$row[OSName]) 
       echo "selected"; 
       echo ">$row[OSName]</option>"; 
       } 
       echo 
    "</select><br></tr></td>"; 
       }
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    That would be because the value of the "value" attribute is not quoted.
    A space has special meaning in HTML tags. It separates attributes from each other.

    So, in your HTML, which would look something like this:
    [code=html]
    <option value=Commitee Members>Commite e Members</option>[/code]
    The "value=Commitee " part would be consider an attribute and it's value, and the "Members" part considered a completely different attribute.
    And because there is no such thing as a "Members" attribute, it would be ignored completely.

    You should ALWAYS enclose attribute values in quotes, or risk running into problems like these.

    Comment

    • ddtpmyra
      Contributor
      • Jun 2008
      • 333

      #3
      Your awesome! It works thanks for the information Atli

      Comment

      Working...