news system...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
teksys
Forum Commoner
Posts: 34
Joined: Tue May 14, 2002 6:58 pm
Location: Denmark

news system...

Post by teksys »

i have written a fairly simple news system, allows users to edit/delete/add news.

everything works well..except for one thing - i want to be able to view a specific news topic by quering thepage.php?something=NEWSID and have that display a specific news-ID...not all of the news..now i have it so that all of the news (max 10 topics) shown on the index page...

anyone got any simple code for doing something i want?

-- teksys
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

where do you store the news? is it a database?
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

i don't really understand what you are on about but here it is if you are useing DB:

to get ID etc do this:

Code: Select all

<?php
$sql = "SELECT ID, etc FROM tablename";
$results = mysql_query($sql);
while(list($ID,etc) = mysql_fetch_row($results))
&#123;
Print("<a href='?id=$ID'>etc</a><br>");
&#125;
?>
then put this on another page.

Code: Select all

<?php
if(IsSet($id)
&#123;
&#125;
else
&#123;
$id="1"; //if id is not with the page name then it it will show the first news in the DB
&#125;

$sql = "SELECT ID, etc  FROM tablename WHERE ID='$id';
$results = mysql_query($sql);
$get = mysql_fetch_array($results);

?>
and to print it all you have to do is:

Code: Select all

print("$get&#1111;fieldname]");
i just wrote this right here so i dobn't know if anything is worng with it.
just post back here if there is.

hope this helps.
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post by lc »

really depends on how you store the data. I use flatfiles all the time and the way I do it is to use a single line for each article, then tell the script to only load one at a time.

Maybe this script I wrote can give you some ideas. http://www.alienhelpdesk.com/freescripts.php?id=16
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

well now you got both, db and flat files, uuse any you like :wink:
User avatar
teksys
Forum Commoner
Posts: 34
Joined: Tue May 14, 2002 6:58 pm
Location: Denmark

mmm

Post by teksys »

I use a MySQL database/table for my news system. I'll try out the above code, really soon...........thanks!
User avatar
teksys
Forum Commoner
Posts: 34
Joined: Tue May 14, 2002 6:58 pm
Location: Denmark

blah

Post by teksys »

it didn't work...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What about it didn't work? Did you get error messages or did it just not work as expected?

Mac
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

well, you could use this script i wrote for my site, i use it my self:
http://www.qadsscripts.t2u.com
PHPNews is the script name.[/url]
Post Reply