Setting a variable in URL
Posted: Mon Mar 13, 2006 12:09 pm
I'm trying to make a script to call certain rows from a table according to the a catagory called.
so if i would click the link to /list.php?yearcat=9904
the rows pulled would only match the year catagory called
so if i would click the link to /list.php?yearcat=9904
the rows pulled would only match the year catagory called
Code: Select all
ini_set('display_errors',true);
if ($yearcat==05up)
{
$cat="05up" ;
} elseif ($yearcat==9904)
{
$cat="9904";
}elseif ($yearcat==9498)
{
$cat="9498";
}elseif ($yearcat==8793)
{
$cat="8793";
}elseif ($yearcat==7986)
{
$cat="7986";
}
$host="****";
$user="*****";
$pass="l*****";
$db="******";
$tablename="******";
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
//run query
$query = 'SELECT * FROM $tablename WHERE (yearcat= '$cat')';
if ($r = mysql_query ($query))
{
//print
while ($row = mysql_fetch_array ($r))
{
print "{$row['name']}";
}
else {die('error');
}
mysql_close();
?>