Page 1 of 1

Playing with GET

Posted: Tue Nov 30, 2004 7:31 pm
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>";

Posted: Tue Nov 30, 2004 8:12 pm
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'];
}
?>

Posted: Wed Dec 01, 2004 12:02 am
by kgray
LOL, thanks alot. I cannot believe I missed such a simple mistake.

Ken