472,972 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,972 software developers and data experts.

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("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.

Aug 14 '06 #1
3 4336

cp**********@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.
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("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 :)
cp**********@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.
Aug 14 '06 #3
"Robert" <ro*******@gmail.comwrote in news:1155543441.183922.320090
@m79g2000cwm.googlegroups.com:

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

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

Similar topics

1
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...
3
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...
2
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........> ..........
10
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...
7
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>...
14
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 ;...
2
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...
9
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...
4
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...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.