php - adding a news article auto creates page for it


ok did a quick read, so is the intvl just a security thing?

so how does the page know to read whats after the ? in the address bar?

say in the future i want to select all articles in category='home' and author='admin' how would i do this?

I'm guesig its relatively easy just don't know exaclty how? just add a , after each one possible?
 
yup, intval is just for security/error checking purposes.

as for the next part, you could call the page like this.....

Code:
articles.php?author=admin&category=home

then you would code something like this

Code:
<?php
//db connect
$author = mysql_real_escape_string($_GET['author']);
$category = mysql_real_escape_string($_GET['category']);
$result = mysql_query("SELECT * FROM table WHERE author = '$author' AND category = '$category' ORDER BY date_posted DESC");
while($row = mysql_fetch_assoc($result)) {
    //list articles
}
?>

i just stuck the "order by date_posted desc" on the end so you get the newest articles first. obviously you'd need to change the column names to match your db. :)
 
Back
Top Bottom