View Single Post
Old 10-17-2012, 06:30 PM   PM User | #1
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
do query based on a var

Hi, is this the best way to switch a query

PHP Code:
$index $_GET['index'];
if (
$index==1$index=1;

if (
$index==1$query1 "SELECT COUNT(*) as num FROM $tbl WHERE test='1'";
else 
$query1 "SELECT COUNT(*) as num FROM $tbl WHERE ip LIKE '$key'"
Thanks
Sonny

Last edited by sonny; 10-17-2012 at 06:58 PM..
sonny is offline   Reply With Quote