Page 1 of 1

server query to eliminate ?id= from a dynamic inclusion

Posted: Fri May 14, 2004 8:34 pm
by onesweetmoment
Hi,

I have recently updated all my dynamic inclusion files to:

Code: Select all

<?php 

if($_GET['band']) 
{
$id = $_GET['band']; 
include("bands/" . $id . '.php'); 
}
else 
{
include("bands/band_index.php");
}

?>
I was just curious as to whether it would be possible to eliminate the "band=" i.e bands.php?nirvana instead of bands.php?band=nirvana...

Any help gratefully appreaciated..

Posted: Sat May 15, 2004 12:12 am
by feyd
something like this?

Code: Select all

if(!empty($_GET))
{
  foreach($_GET as $k => $v)
  {
    if(preg_match("/^[a-z0-9_]+$/i",$k) && is_file("bands/$k.php"))
    {
      include("bands/$k.php");
      break;
    }
  }
}
else
{
  include("bands/band_index.php");
}

Posted: Sat May 15, 2004 4:28 pm
by onesweetmoment
Yeah that works perfectly! Thanks so much! :D