You are here: Re: PLEASE HELP - How to add URL to options in drop down list « PHP Programming Language « IT news, forums, messages
Re: PLEASE HELP - How to add URL to options in drop down list

Posted by Karl Groves on 10/07/23 11:55

"Robert" <robertark@gmail.com> wrote in news:1155543441.183922.320090
@m79g2000cwm.googlegroups.com:


> cpptutor2000@yahoo.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("SELECT DISTINCT year, semester, school,
>> schoolurl FROM
>> schoolproject_pics ORDER
BY
>> year");
>> echo "<select name=\"semester\">";
>> while(list($year, $semester, $school, $schoolurl) =
>> mysql_fetch_array($sql_query)){
>> echo "<option value=\"$year\">$year $semester <a
>> href=\"$schoolurl\">$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("SELECT DISTINCT year, semester, school,
> schoolurl FROM schoolproject_pics ORDER BY year");
> echo "<select name=\"semester\">";
> while(list($year, $semester, $school, $schoolurl) =
> mysql_fetch_array($sql_query))
> {
> echo "<option value=\"$year\"
> onclick=\"window.open('$schoolurl');\">$school ($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
www.karlcore.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация