Jump to content

Need help with URL parameters . . .


mediabob

Recommended Posts

Hi, I am trying to get a URL parameter and use a case statement to insert a word based on the value of the parameter, but no matter what I do the value of the parameter always comes up as 1. My url is like this:

 

http://mysite.com/test/example_page.php?example=3&catid=1

 

The second parameter, cat_id is the one I am having trouble with, I am using this code:

 

if (isset($_GET['catid'])) {
  $catname = (get_magic_quotes_gpc()) ? $_GET['catid'] : addslashes($_GET['catid']);
}
switch ($catname)
{
case 0: $name = 'test1' && $section = "1"; break;
case 1: $name = 'test2' && $section = "2"; break;

//This is example there are more case statements . . .

 

When doing this, the second part  "$section" always comes up with the correct value but the first one, "$name" Always comes up as 1, I don't even know where this 1 is coming from

 

Any help would be greatly appreciated

Link to comment
https://forums.phpfreaks.com/topic/60340-need-help-with-url-parameters/
Share on other sites

Well, this is for a dynamic page that is going to be re-used, so name is the db table to querry and section is the column to compare with so you would have

 

Select * From $name where $section = something

 

This way it uses the correct table depending on where the user came from.

 

 

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.