Playing with GET

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kgray
Forum Newbie
Posts: 4
Joined: Sat Nov 27, 2004 11:53 am

Playing with GET

Post by kgray »

Please forgive how ugly the code is, just playing around trying to figure out how things work in PHP.

Trying to figure out how to use _GET().

I can pass and grab a single variable, but when I uncomment the code for the second variable I run into problems. Script will run until a link is clicked.

How do you grab the second variable being passed?

Thanks,
Ken

Code: Select all

echo "<html><title>Get Test</title><head></head><body>";

if(!isset($_GET['cat']))
		{$cat="0";}
	else
		{$cat=$_GET['cat'];}
		
/*if(!isset($_GET['cid']))
	{$cid="0";}
else
	{$cid=$_GET('cid');}
*/
echo "</p>CAT: ".$cat;
echo "<br />CID: ".$cid;

$title = "Test";
for ($i = 0; $i <= 10; $i++)
	{
	$cat= $cid*2;
	$cid++;
	echo "<br /><a href="$self?cat=$cat&cid=$cid">$title</a>\r\n";
	}
echo "</body></html>";
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you have some errors

Code: Select all

<?php

if(!isset($_GET['cid']))    
{
$cid="0";
}
else
{
$cid=$_GET('cid');
}
?>
should be

Code: Select all

<?php

if(!isset($_GET['cid']))    
{
$cid="0";
}
else
{
$cid=$_GET['cid'];
}
?>
kgray
Forum Newbie
Posts: 4
Joined: Sat Nov 27, 2004 11:53 am

Post by kgray »

LOL, thanks alot. I cannot believe I missed such a simple mistake.

Ken
Post Reply