Jump to content

checking to see if a $_GET variable is something or another


dazzclub

Recommended Posts

Hi guys i would like to check if a variable has been set and to find out wether its a particular number and which then takes it to the write page.

 

i have two numbers i would like to check for, 67 and 68.

 

If its 68 go here else go 67.

 

here is my function so far;

function subLevels()
{
if ((isset($_GET['cat_id']) ) && (isset($_GET['sublvl_id'])) && (is_numeric($_GET['cat_id'])) && (is_numeric($_GET['sublvl_id'])) ) { //correctly accessed 
$cat_id=$_GET['cat_id'];
$sublvl_id=$_GET['sublvl_id'];

} else { 
$errors[] = 'You have accessed this page incorrectly.'; 
}
global $dbc;
$query ="SELECT * FROM SubCat1 WHERE CategoryID = $cat_id AND SubLevelID = $sublvl_id
	ORDER BY SubCatID";		
$result = mysqli_query ($dbc, $query)or die(mysqli_error() . "<p>With query:<br>$query");
while ($row = mysqli_fetch_assoc($result))
{
//need to format the date on this function
//get NewsID
echo "<li><a href=\"industrial.php?medical_product=$row[CategoryID]&sublvl_id=$row[subLevelID]&subcat_id=$row[subCatID]\">$row[subCatName]</a></li>";	
}
}

 

Any help would be grea! :)

I would probably break it down a little, something like this:

 

if(isset($_GET['cat_id']) && isset($_GET['sublvl_id'])) {

if($_GET['cat_id'] == "67" || $_GET['cat_id'] == "68") {
// do something
} else {
// do something else
}

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.