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
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.

 

 

Link to comment
Share on other sites

case 0: $name = 'test1' && $section = "1"; break;

 

You use logical and but use assignment oiperator, which is a logical error.

 

You can try like this

case 0: $name == 'test1' && $section == "1"; break;

 

--

Tapos Pal

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.