Hello, What is happening is the program I have written is getting stuck on the second case. I need to have the last two cases accessible as well... The solution has been eluding me for the past week. Maybe someone on here can point out the issue and give a solution or alternative to the code I have. //check to see if variables are being used on form. if(isset($_GET['thick1']) || isset($_GET['thick2'])){ //if true cycle through cases. switch(1) { case ($_GET['thick1']!="" && $_GET['thick2']!=""): $q="select * from $table where pthick between $_GET[thick1] and $_GET[thick2] order by pthick LIMIT $start,$limit"; break; case ($_GET['thick1']=="" && $_GET['thick2']==""): $q="select * from $table where pthick like '%$_GET[thick1]%' order by pthick LIMIT $start,$limit"; //this case is where I seem to have the problem on each of the three switch //statements break; case ($_GET['thick1']!="" && $_GET['thick2']==""): $q="select * from $table where pthick = $_GET[thick1] order by pthick LIMIT $start,$limit"; break; case ($_GET['thick1']=="" && $_GET['thick2']!=""): $q="select * from $table where pthick = $_GET[thick2] order by pthick LIMIT $start,$limit"; break; } } if(isset($_GET['height1']) || isset($_GET['height2'])){ switch(1) { case ($_GET['height1']!="" && $_GET['height2']!=""): $q="select * from $table where pwidth between $_GET[height1] and $_GET[height2] order by pwidth LIMIT $start,$limit"; break; case ($_GET['height1']=="" && $_GET['height2']==""): $q="select * from $table where pwidth like '%$_GET[height1]%' order by pwidth LIMIT $start,$limit"; break; case ($_GET['height1']!="" && $_GET['height2']==""): $q="select * from $table where pwidth = $_GET[height1] order by pwidth LIMIT $start,$limit"; break; case ($_GET['height1']=="" && $_GET['height2']!=""): $q="select * from $table where pwidth = $_GET[height2] order by pwidth LIMIT $start,$limit"; break; } } if(isset($_GET['date1']) || isset($_GET['date2'])){ switch(1) { case ($_GET['date1']!="" && $_GET['date2']!=""): $q="select * from $table where pdate between $_GET[date1] and $_GET[date2] order by pdate LIMIT $start,$limit"; break; case ($_GET['date1']=="" && $_GET['date2']==""): $q="select * from $table where pdate like '%$_GET[date1]%' order by pdate LIMIT $start,$limit"; break; case ($_GET['date1']!="" && $_GET['date2']==""): $q="select * from $table where pdate = $_GET[date1] order by pdate LIMIT $start,$limit"; break; case ($_GET['date1']=="" && $_GET['date2']!=""): $q="select * from $table where pdate = $_GET[date2] order by pdate LIMIT $start,$limit"; break; } } PHP:
//check to see if variables are being used on form. if(isset($_GET['thick1']) || isset($_GET['thick2'])){ //if true cycle through cases. if ($_GET['thick1']!="" && $_GET['thick2']!="") { $q="select * from $table where pthick between $_GET[thick1] and $_GET[thick2] order by pthick LIMIT $start,$limit"; } elseif ($_GET['thick1']=="" && $_GET['thick2']=="") { $q="select * from $table where pthick like '%$_GET[thick1]%' order by pthick LIMIT $start,$limit"; } elseif ($_GET['thick1']!="" && $_GET['thick2']=="") { $q="select * from $table where pthick = $_GET[thick1] order by pthick LIMIT $start,$limit"; } elseif ($_GET['thick1']=="" && $_GET['thick2']!="") { $q="select * from $table where pthick = $_GET[thick2] order by pthick LIMIT $start,$limit"; } } PHP: Let me know if that works.
Hello you can test out the current version at http://www.bitsonline.us/don/advsearch.html I will have the query shown so you can see where it gets stuck. I will add your code you gave me and comment it out until you have seen what is going on. Btw Thanks for the snippet of code. Hope it works.
instead of using $_GET['thick2']!="" to see if it is blank, use the empty variable like this: if (!empty($_GET['thick1']) && (!empty($_GET['thick2']) { PHP: Change all your statements to do it that way instead. "!empty" makes sure it is not empty, and "empty" makes sure it is empty.