if(!$_GET['categ_id']) $_GET['categ_id'] = 6; Code (markup): tried $category = isset($_GET['categ_id']) ? $_GET['categ_id'] : rand(1,3,8,5); Code (markup): can i call random numbers?
Since mt_rand and rand use a range, I would use an array of available numbers. Something like this. $allowed = array(1,3,8,5); $category = isset($_GET['categ_id']) ? (int) $_GET['categ_id'] : $allowed[array_rand($allowed)]; PHP:
I was going to post: $category = isset($_GET['categ_id']) ? $_GET['categ_id'] : rand(1,8); // if you want a random number between 1 and 8 echo $category . "<br />\n"; $arr = array(1,3,8,5); $category2 = isset($_GET['categ_id2']) ? $_GET['categ_id2'] : $arr[array_rand($arr,1)]; // if you want only the numbers listed in the array echo $category2; Code (markup):