TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Cant u switch with the use of cat=1 cat=2 etc? [!Read!] (http://www.talkphp.com/absolute-beginners/3025-cant-u-switch-use-cat-1-cat-2-etc-read.html)

codefreek 06-28-2008 06:06 PM

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!

Evulness 06-29-2008 04:03 PM

err, let me get this straight, you kind of confused me...

are you looking for a swticher?

PHP: switch - Manual

or your looking to properly loop out each category as a link?

i think i see where you are heading with this script.... Your checking to see if there are any news items in the database, and if there are you want to output a link for each item.

or are you trying to see if the requested $_GET['cat'] is i n the database, and if so, output a link to it?

or are you trying to set up a switcher, that pulls all news items from requested category?

i'm sorry you need to be a little more specific.

codefreek 06-29-2008 10:30 PM

you are so lost :)
i wonder why my code is not working as i do in the other script i use and my question was is it because i use links on the other one and not on this is that the problem..
read please..


All times are GMT. The time now is 02:05 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0