Two switch statements on same page
Posted: Sat May 28, 2011 1:29 pm
Ok, I've been messing around with this for a while and I can't seem to figure it out. I'm wanting to have 2 different switch statements on the same page. The page works great with 1, but when I add in the second one, nothing happens. Any help would be great, the code is below.
If you take out the second switch, everything is great. Once I add in the alpha switch back in, the page no longer loads anything. I'm not 100% sure this should even work like this, but I thought I would post it anyway.
If you take out the second switch, everything is great. Once I add in the alpha switch back in, the page no longer loads anything. I'm not 100% sure this should even work like this, but I thought I would post it anyway.
Code: Select all
<?php
include("../include/opendbconnection.php");
$category = $_GET['category'];
switch($category)
{
case "American";
case "Asian";
$q="Select * from tbl_restaurantinfo WHERE category='".$category."' and hours != 'Closed' ORDER BY name";
break;
default;
echo "Something Went Wrong";
}
$alpha = $_GET['alpha'];
switch($alpha)
{
case "$alpha";
$q="Select * FROM tbl_restaurantinfo Where name Like '$alpha' and hours != 'Closed' ORDER BY name";
break;
}
$rs=mysql_query($q) or die(mysql_error());
$nr = mysql_num_rows($rs); //Number of rows found with LIMIT in action
$q0="Select FOUND_ROWS()";
$rs0=mysql_query($q0) or die(mysql_error());
$row0=mysql_fetch_array($rs0);
$nr0 = $row0["FOUND_ROWS()"];
while ($row=mysql_fetch_array($rs))
{
echo $row['display_name'];
echo "<br />";
}
?>