drop down menu from database query

Discussion in 'PHP' started by bryan castle, Apr 19, 2007.

  1. #1
    here is my query
    SELECT E.EID,CONCAT(CONCAT(E.LAST_NAME,', '),E.FIRST_NAME) AS ENAME,(CASE WHEN E.END_DATE>SYSDATE THEN 1 ELSE 0 END) AS ACTIVE,D.DIVISION_NAME FROM PARKING.EMPLOYEE E LEFT OUTER JOIN PARKING.PTS_DIVISION D ON D.DIVISION_ID=E.EMP_DIVISION_FK ORDER BY E.LAST_NAME,E.FIRST_NAME
    i want to drop the result into a drop down menu in my form.
    can i get alittle assitance with this..
     
    bryan castle, Apr 19, 2007 IP
  2. Kalyse

    Kalyse Peon

    Messages:
    1,221
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $query = "SELECT E.EID,CONCAT(CONCAT(E.LAST_NAME,', '),E.FIRST_NAME) AS ENAME,(CASE WHEN E.END_DATE>SYSDATE THEN 1 ELSE 0 END) AS ACTIVE,D.DIVISION_NAME FROM PARKING.EMPLOYEE E LEFT OUTER JOIN PARKING.PTS_DIVISION D ON D.DIVISION_ID=E.EMP_DIVISION_FK ORDER BY E.LAST_NAME,E.FIRST_NAME";
    $result = mysql_query($query);
    echo "<select name='names'>";
    
    while($row = mysql_fetch_assoc($result)) {
    extract($row);
    
    echo "<option value='$value'>$value</option>"
    
    }
    
    
    echo "</select";
    
    PHP:
    I cant be bothered to look to see what the query atually does, you need to change the $value to the name of the field.
     
    Kalyse, Apr 19, 2007 IP