Hey,

I know this is a stupid way of doing it, hence the question..:

How can i do this smarter:

if (($url == 'billeder') or ($url == 'billeder=1' or $url == 'billeder=2' or $url == 'billeder=3' or $url == 'billeder=4'))
{
include("includes/billeder.php");
}

I just want to see if the number behind the ? in the $_GET is an integer, and if it is then include the file.

'billeder="value"', could increase or decrease, and therefor it is the most lame solution i have found, since, the script i not dynamic, and changes to whatever the get value is.

But i think as long as i tjeck if it is an integer at the very end, it would be fine.

Hope someone can lead the way, as my logic is not helping me at the moment!

Recommended Answers

All 5 Replies

$value = $_GET['billeder'];
if (is_numeric($value))
{
  include("includes/billeder.php");
}
// get last digit from url
$grablast = substr($url, -1);

// test url if it equals billeder or if last digit is 0 or greater then zero 
	if ($url == "billeder") {$check = "yes";} 
	if(is_numeric($grablast)){
	if ($grablast >= 0) {$check = "yes";}
	}

// if check is yes that the variable is billeder or a number include page
  if ($check == "yes")
  {
   include("includes/billeder.php");
   }

haha one day struggling and figthing with crasy ajax requests, and the next day I cant find the value of a link :-)

Solved, thanks for helping pritaeas..

Thanks HITMANOF44th, thats also a very nice approach!

thats why you have to love programming 101 ways to hammer in the same nail

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.