PLEASE HELP - How to add URL to options in drop down list

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cpptutor2000@yahoo.com

    PLEASE HELP - How to add URL to options in drop down list

    Could some PHP guru please help me? I am have a drop down list, whose
    options are read in dynamically from a table in a MySQL database. one
    of the items being read in is an URL. I am
    unable to display this URL in the drop down list. The following is the
    code snippet I am using:

    $sql_query = mysql_query("SE LECT DISTINCT year, semester, school,
    schoolurl FROM
    schoolproject_p ics ORDER BY
    year");
    echo "<select name=\"semester \">";
    while(list($yea r, $semester, $school, $schoolurl) =
    mysql_fetch_arr ay($sql_query)) {
    echo "<option value=\"$year\" >$year $semester <a
    href=\"$schoolu rl\">$school</a></option>";
    }

    When the drop down list is displayed, I do not see the URL. Could
    someone please point out what exactly I am doing wrong? Thanks in
    advance for your help, any help would be greatly appreciated.

  • flamer die.spam@hotmail.com

    #2
    Re: PLEASE HELP - How to add URL to options in drop down list


    cpptutor2000@ya hoo.com wrote:
    Could some PHP guru please help me? I am have a drop down list, whose
    options are read in dynamically from a table in a MySQL database. one
    of the items being read in is an URL. I am
    unable to display this URL in the drop down list. The following is the
    code snippet I am using:
    >
    $sql_query = mysql_query("SE LECT DISTINCT year, semester, school,
    schoolurl FROM
    schoolproject_p ics ORDER BY
    year");
    echo "<select name=\"semester \">";
    while(list($yea r, $semester, $school, $schoolurl) =
    mysql_fetch_arr ay($sql_query)) {
    echo "<option value=\"$year\" >$year $semester <a
    href=\"$schoolu rl\">$school</a></option>";
    }
    >
    When the drop down list is displayed, I do not see the URL. Could
    someone please point out what exactly I am doing wrong? Thanks in
    advance for your help, any help would be greatly appreciated.
    you can't have <tags inside of an <optiontag, you can either just
    display the url inline, $year $semester $school, or you will need to
    put it in the option value field and put $year elsewhere.

    Flamer.

    Comment

    • Robert

      #3
      Re: PLEASE HELP - How to add URL to options in drop down list

      Try using this:

      $sql_query = mysql_query("SE LECT DISTINCT year, semester, school,
      schoolurl FROM schoolproject_p ics ORDER BY year");
      echo "<select name=\"semester \">";
      while(list($yea r, $semester, $school, $schoolurl) =
      mysql_fetch_arr ay($sql_query))
      {
      echo "<option value=\"$year\"
      onclick=\"windo w.open('$school url');\">$schoo l ($year
      $semester)</option>";
      }

      Hope it helps.. You cannot have an href inside of an option display.
      But you can use some nifty JS to help you out :)
      cpptutor2000@ya hoo.com wrote:
      Could some PHP guru please help me? I am have a drop down list, whose
      options are read in dynamically from a table in a MySQL database. one
      of the items being read in is an URL. I am
      unable to display this URL in the drop down list. The following is the
      code snippet I am using:
      >
      $sql_query = mysql_query("SE LECT DISTINCT year, semester, school,
      schoolurl FROM
      schoolproject_p ics ORDER BY
      year");
      echo "<select name=\"semester \">";
      while(list($yea r, $semester, $school, $schoolurl) =
      mysql_fetch_arr ay($sql_query)) {
      echo "<option value=\"$year\" >$year $semester <a
      href=\"$schoolu rl\">$school</a></option>";
      }
      >
      When the drop down list is displayed, I do not see the URL. Could
      someone please point out what exactly I am doing wrong? Thanks in
      advance for your help, any help would be greatly appreciated.

      Comment

      • Karl Groves

        #4
        Re: PLEASE HELP - How to add URL to options in drop down list

        "Robert" <robertark@gmai l.comwrote in news:1155543441 .183922.320090
        @m79g2000cwm.go oglegroups.com:

        cpptutor2000@ya hoo.com wrote:
        >Could some PHP guru please help me? I am have a drop down list, whose
        >options are read in dynamically from a table in a MySQL database. one
        >of the items being read in is an URL. I am
        >unable to display this URL in the drop down list. The following is
        the
        >code snippet I am using:
        >>
        > $sql_query = mysql_query("SE LECT DISTINCT year, semester, school,
        >schoolurl FROM
        > schoolproject_p ics ORDER
        BY
        >year");
        > echo "<select name=\"semester \">";
        > while(list($yea r, $semester, $school, $schoolurl) =
        >mysql_fetch_ar ray($sql_query) ){
        > echo "<option value=\"$year\" >$year $semester <a
        >href=\"$school url\">$school</a></option>";
        > }
        >>
        >When the drop down list is displayed, I do not see the URL. Could
        >someone please point out what exactly I am doing wrong? Thanks in
        >advance for your help, any help would be greatly appreciated.
        >
        >
        :: top posting fixed ::
        Try using this:
        >
        $sql_query = mysql_query("SE LECT DISTINCT year, semester, school,
        schoolurl FROM schoolproject_p ics ORDER BY year");
        echo "<select name=\"semester \">";
        while(list($yea r, $semester, $school, $schoolurl) =
        mysql_fetch_arr ay($sql_query))
        {
        echo "<option value=\"$year\"
        onclick=\"windo w.open('$school url');\">$schoo l ($year
        $semester)</option>";
        }
        >
        Hope it helps.. You cannot have an href inside of an option display.
        But you can use some nifty JS to help you out :)

        Why use the above method? It not only relies on javascript to work, but
        also opens a new window. You may as well add an alertbox telling the
        user you hate them.



        --
        Karl Groves

        Comment

        Working...