473,799 Members | 3,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.

Aug 14 '06 #1
3 4386

cp**********@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.

Aug 14 '06 #2
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 :)
cp**********@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.
Aug 14 '06 #3
"Robert" <ro*******@gmai l.comwrote in news:1155543441 .183922.320090
@m79g2000cwm.go oglegroups.com:

cp**********@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
www.karlcore.com
Aug 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8273
by: CG | last post by:
Hi, I have a drop down list on an asp page. Can I have tooltips for each item so when the user scrolls odwn through the drop down I display a tooltip (as some options are long and I do not want to incrase the width of my drop down). Thanks,
3
23335
by: Darren | last post by:
Please Help Me!! I've created a typical <form> and a <select> element. The options are created dynamically from my access database (using asp). There are about 70 options, and when you click the dropdown button, it shows about 25 (depending on screen resolution) and then the gives you a scroll bar to get to the rest. My question is, can I limit the number of options shown when you click
2
4362
by: Adam Smith | last post by:
I am developing a Form to be used for data input into a database. To limit errors in fields I want to input some data using "<SELECT NAME=xxxxx> <OPTIONS VALUE=yyyyy> <OPTIONS VAL........> ....... </SELECT>". The problem is that some of the menu lists to be presented are very large for a single drop down menu, 400 - 500 entries. I can break them up into shorter menus according to alphabetical ordering but can I use several "<SELECT...
10
3488
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the there is no drop down menu functionality at all. I wanted to implement an alternative stylesheet for IE, but my link to it is apparently broken. What is wrong with my link? I'd
7
3617
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title> </head> <style type="text/css">
14
3113
by: alwayshouston | last post by:
Hi All! I am working on this very small database and I am confused in the designing a simple form. I only have three tables in the database. First Table: tblExpense Columns: ExpenseID ; ExpenseType Data: 1 ; FOOD 2 ; AIRLINE 3 ; FARE
2
1086
by: Martin Schmid | last post by:
I've got a page w/ frames... one is a navigation frame with some ImageButtons. In the navigation frame, there is also a drop-down list. I need to redirect the mainFrame based on which ImageButton is selected, and which value is selected in the drop-down list. I.e., each ImageButton is a thumbnail image, and the dropdown lets the viewer select the result size of the image... 25%, 50%, 100%. I need to dynamically generate something that...
9
1892
by: Coleen | last post by:
Hi All :-) I am desperately looking for some help/information on how to direct page flow. Forget what I have done - here's what I need to do: I have a large ASPX.Net - VB.Net web application (around 35-40 pages) that once the user logs in, I need to direct them to the correct page, depending on what they select from the directory. In other words...when they login, if they are a new user, a new account screen comes up and from there a...
4
1957
by: teknoshock | last post by:
I have created a page with multiple drop down boxes, all populated with the same options. My problem is, for 12 dropdown boxes and 40 choices per box, I end up with a massive file. Also, if I want to change or add options to a drop down box, I then have to copy that to the other 11 boxes. Would it be possible to define the options once, and then have all of the drop down boxes get their options from the single list? Here is my...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.