I am new to php and MySQL. I have a site where a user can choose a state and display hospitals in that state. It works well in FireFox for all states, but in IE, when I have state with a couple hundred hospitals, the screen flashes and I eventually get a message that the page cannot be displayed. For smaller states with a few hospitals, the query works fine in IE.
Again, I am new to this so any suggestions would be greatly appreciated. Here's the code:
<form action="redirect_hosp.php" method="get">
<?php
$link = mysql_connect('SERVERNAME.com', 'USERNAME', 'PASSWORD');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
/*print 'Connected successfully';*/
mysql_select_db(it_phys);
$sql = "SELECT distinct(state) FROM hospitals ORDER BY state";
$rs = mysql_query($sql)or die("Connection to DataBase failed");
print ("<div align=center>");
print("<font color='#008000' size='2' face='Tahoma'><b>Find a Hospital</b></font><br><br>");
print ("Select a State<br>");
print ("<SELECT name='State' onchange='form.submit();'>");
print("<OPTION value='none' selected></OPTION>\n");
for($i = 0; $i < mysql_num_rows( $rs ); $i++)
{
$tmp = mysql_fetch_row( $rs );
print("<OPTION value=\"$tmp[0]\">$tmp[0]</OPTION>\n");
}
print ("</SELECT>");
print ("</div>");
mysql_free_result($rs);
mysql_close($link);
?>
<?php
if(isset($_GET['State']))
{
$State=$_GET['State'];
print "<div align=center><br><br>";
print "State Selected: ".$State;
print "<br><br></div>";
/* run query to pull members based on state */
$link = mysql_connect('SERVERNAME.com', 'USERNAME', 'PASSWORD');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
/*print 'Connected successfully';*/
mysql_select_db(it_phys);
$query = "SELECT
hospitals.`Hospital Name`, hospitals.Address1,
concat(rtrim(hospitals.City),', ',rtrim(upper(hospitals.State)), ' ', hospitals.zip) as City_State,
hospitals.state,hospitals.`Phone Number`,hospitals.`Hospital Type`,hospitals.`Emergency Service`,
hospitals.map
FROM hospitals WHERE hospitals.state='".$State."' ORDER by hospitals.`Hospital Name`";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
/* show in table */
// Printing results in HTML
print "<style>
h2 { border-bottom: 3px solid red; }
table { border-bottom: 1px solid blue; align='left'; cellpadding=0; cellspacing=0 }
td {border-bottom: 0px outset black; cellpadding=0 }
</style>";
print "<div align=center>";
print "<table cellpadding='20'>";
$i=0;
$rows=mysql_num_rows($result);
while($i < $rows) {
print "<tr>";
print "<style> td {border-bottom: 3px outset green; }</style>";
print "<td valign='top' align='left'>";
print "<font color='red'><strong>".mysql_result($result, $i, 0)."</strong></font>";
print "<br>".mysql_result($result, $i, 1);
print "<br><font color='red'>".mysql_result($result, $i, 2)."</font>";
print "<br>".mysql_result($result, $i, 4);
print "</td>";
print "<td width=350 valign='top' align='left'>";
print "<br>Type: ".mysql_result($result, $i, 5);
print "<br>Emergency Care: ".mysql_result($result, $i, 6);
print "<br><br>";
print "<a STYLE='text-decoration:none' target='_blank'
href='http://maps.google.com/maps?f=q&source=s_q&hl=en&q="
.mysql_result($result, $i, 7)."'><b> Show Map</b></a>";
print "</td>";
print "</tr>";
$i=$i+1;
}
mysql_free_result($result);
mysql_close($link);
}
print "</table>"
?>