Page 1 of 1
news system...
Posted: Wed Jun 12, 2002 8:05 am
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
Posted: Wed Jun 12, 2002 8:23 am
by volka
where do you store the news? is it a database?
Posted: Wed Jun 12, 2002 9:05 am
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))
{
Print("<a href='?id=$ID'>etc</a><br>");
}
?>
then put this on another page.
Code: Select all
<?php
if(IsSet($id)
{
}
else
{
$id="1"; //if id is not with the page name then it it will show the first news in the DB
}
$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:
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.
Posted: Wed Jun 12, 2002 6:16 pm
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
Posted: Thu Jun 13, 2002 4:34 am
by qads
well now you got both, db and flat files, uuse any you like

mmm
Posted: Thu Jun 13, 2002 4:37 am
by teksys
I use a MySQL database/table for my news system. I'll try out the above code, really soon...........thanks!
blah
Posted: Fri Jun 14, 2002 12:57 am
by teksys
it didn't work...
Posted: Fri Jun 14, 2002 1:55 am
by twigletmac
What about it didn't work? Did you get error messages or did it just not work as expected?
Mac
Posted: Fri Jun 14, 2002 3:44 pm
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]