dazzclub Posted March 31, 2009 Share Posted March 31, 2009 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! Link to comment https://forums.phpfreaks.com/topic/151903-checking-to-see-if-a-_get-variable-is-something-or-another/ Share on other sites More sharing options...
PHP Monkeh Posted March 31, 2009 Share Posted March 31, 2009 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 } } Link to comment https://forums.phpfreaks.com/topic/151903-checking-to-see-if-a-_get-variable-is-something-or-another/#findComment-797664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.