C
cargo303
I have a php page with a drop down list, and the default selected
option is "Select a location" (without quotes).
Using the drop down initiates a database query. One of (3) things
should happen:
1. If an option is selected for which results are available, they
should be displayed on the same page beneath the drop down list in a
table.
2. If an option is selected for which results are NOT available, a
message should be displayed informing the visitor that there were no
results for that query.
3. If the default selected option has not yet been changed (ie: when
the page first loads), no message should display.
#1 and #2 work, but the message described in #2 is still displayed when
the page first loads before the default selected option is changed (#3)
but in Internet Explorer only. Firefox displays the page correctly
under all three conditions.
The message that I want hidden on page load is wrapped in a div named
"infobox" and I'm using the following script to hide it which is at the
bottom of the page:
<script language="javascript" type="text/javascript">
function ClearDiv()
{
if
(document.form2.name.options[document.form2.name.selectedIndex].value=="Select
a location")
{
document.getElementById("infobox").style.display =
"none";
}
}
ClearDiv();
</script>
I've also included the php code that writes out the message and the
table below.
Any help would be appreciated.
<?php
$dbh=mysql_connect ("localhost", "USERNAME", "PASSWORD") or die ('I
cannot connect to the database because: ' . mysql_error());
mysql_select_db ("USERNAME",$dbh);
$query = "SELECT city, state, station, URL, call_letter, request_line,
phone_line FROM radio_location WHERE state='$_GET[name]' ORDER BY
city";
//echo $query;
$result = mysql_query($query,$dbh);
$resultnum = mysql_num_rows($result);
if ($resultnum == 0) {
echo '<tr id="sorry"><td><div id="infobox">Sorry, there are no radio
stations <br> in' .' ' . $_GET[name].' ' . 'playing Jake\'s
music</div></td></tr>';
}
else {
// CREATE COLUMN HEADINGS
echo "<tr class='search_results_headings'><td width='90px'>City</td><td
width='50px'>Radio Station<td width='50px'>Call Letters<td>URL</td><td
width=90px'>Request Line</td><td width='90px'>Phone Line</td></tr><br
/>";
}
while ($row = mysql_fetch_array($result))
{
// ++++++++++++++++++++++++++++ BUILD THE TABLE ROWS DYNAMICALLY
++++++++++++++++++++++
echo "<tr><td>$row[city]<td>$row[station]<td>$row[call_letter]<td><A
href='http://$row'target='_blank'>$row[URL]</a><td>$row[request_line]<td>$row[phone_line]";
}
echo "<br>";
mysql_close;
?>
</table>
<br />
<?php
option is "Select a location" (without quotes).
Using the drop down initiates a database query. One of (3) things
should happen:
1. If an option is selected for which results are available, they
should be displayed on the same page beneath the drop down list in a
table.
2. If an option is selected for which results are NOT available, a
message should be displayed informing the visitor that there were no
results for that query.
3. If the default selected option has not yet been changed (ie: when
the page first loads), no message should display.
#1 and #2 work, but the message described in #2 is still displayed when
the page first loads before the default selected option is changed (#3)
but in Internet Explorer only. Firefox displays the page correctly
under all three conditions.
The message that I want hidden on page load is wrapped in a div named
"infobox" and I'm using the following script to hide it which is at the
bottom of the page:
<script language="javascript" type="text/javascript">
function ClearDiv()
{
if
(document.form2.name.options[document.form2.name.selectedIndex].value=="Select
a location")
{
document.getElementById("infobox").style.display =
"none";
}
}
ClearDiv();
</script>
I've also included the php code that writes out the message and the
table below.
Any help would be appreciated.
<?php
$dbh=mysql_connect ("localhost", "USERNAME", "PASSWORD") or die ('I
cannot connect to the database because: ' . mysql_error());
mysql_select_db ("USERNAME",$dbh);
$query = "SELECT city, state, station, URL, call_letter, request_line,
phone_line FROM radio_location WHERE state='$_GET[name]' ORDER BY
city";
//echo $query;
$result = mysql_query($query,$dbh);
$resultnum = mysql_num_rows($result);
if ($resultnum == 0) {
echo '<tr id="sorry"><td><div id="infobox">Sorry, there are no radio
stations <br> in' .' ' . $_GET[name].' ' . 'playing Jake\'s
music</div></td></tr>';
}
else {
// CREATE COLUMN HEADINGS
echo "<tr class='search_results_headings'><td width='90px'>City</td><td
width='50px'>Radio Station<td width='50px'>Call Letters<td>URL</td><td
width=90px'>Request Line</td><td width='90px'>Phone Line</td></tr><br
/>";
}
while ($row = mysql_fetch_array($result))
{
// ++++++++++++++++++++++++++++ BUILD THE TABLE ROWS DYNAMICALLY
++++++++++++++++++++++
echo "<tr><td>$row[city]<td>$row[station]<td>$row[call_letter]<td><A
href='http://$row'target='_blank'>$row[URL]</a><td>$row[request_line]<td>$row[phone_line]";
}
echo "<br>";
mysql_close;
?>
</table>
<br />
<?php