View Single Post
Old 06-28-2008, 06:06 PM   #1 (permalink)
codefreek
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Help Cant u switch with the use of cat=1 cat=2 etc? [!Read!]

I use this code, in my other link system to switch to cat 1 for the first link and then cat 2 for the other links that has the cat_id to 2, or 3 etc..

Quote:
#But now when i try to implement the code to my news system
it some how do not work ? :S
Help would be great
Thank you in advance:


PHP Code:
<?php
$webq 
"select id, name, des from news ";
if(isset(
$_GET['cat']))
 {
   
$webq .= sprintf("where cat_id = '%s'"mysql_real_escape_string($_GET['cat']));
 }
 
$web_result mysql_query($webq);
 if(!
cat_result)
{
echo 
mysql_error();
}
$catq "select id, name from cat";
$cat_result mysql_query($catq);

?>

<?php
while($cat_row mysql_fetch_array($cat_result))
{
?>
<a href="index.php?cat=<?php echo $cat_row['id'];?>"><?php echo $cat_row['name'];?></a>
<?php

?>

Thank you!
codefreek is offline  
Reply With Quote