TalkPHP
 
 
Account Login
Latest Articles
» How to keep your forms from double posting data
» cURL Basics
» Securing your PHP applications Part 1
» The way the function rolls
» Database Abstraction with Zend_Db - Part 2
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 06-28-2008, 06:06 PM   #1 (permalink)
The Addict
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 283
Thanks: 166
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
Old 06-29-2008, 04:03 PM   #2 (permalink)
The Contributor
 
Evulness's Avatar
 
Join Date: Apr 2008
Location: Tampa, FL
Posts: 62
Thanks: 6
Evulness is on a distinguished road
Default

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.
__________________
"Knowledge is power. Abuse it."~Evulness
My portfolio: www.evularts.com
Send a message via AIM to Evulness
Evulness is offline  
Reply With Quote
Old 06-29-2008, 10:30 PM   #3 (permalink)
The Addict
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 283
Thanks: 166
codefreek is on a distinguished road
Default

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..
__________________
inquisitive
1. Eager to acquire knowledge.
2. Too curious; overly interested; nosy.
codefreek is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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

 
     

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