Hi there,
A quick question, i have a simple article website I'm putting together. My database is set up like this;
# articles
id, title, article, created_at, catid
# category
catid, catname
Ive passed a catid through links as below :
<?php
$query = "SELECT catname, catid FROM category";
$result = mysql_query($query) or die(mysql_error());
// make the catogories list and then passes the values on to archive page
$entry = '<ol>';
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
list($catname, $catid) = $row;
$entry .= "<li><a href=\"?view=archive&catid=" . $catid . "\">$catname</a></li>\r\n";
}
$entry .= '</ol>';
// show the categories list
echo $entry;
?>
now it passes " http://localhost/codedad/?view=archive&catid=1 " on to the archive page.
my problem is getting the archive page to display only the articles under the catid=1.
below is the function ive made to display the catitems :
<?php
function displaycatitems()
{
db_connect();
$catid = $_GET["catid"];
if(!isset($_GET['catid']))
{
$query ="SELECT title, article FROM articles, category WHERE cat=category.catid=".$_GET['id'];
$result = mysql_query($query) or die('Error : ' . mysql_error());
while($row = mysql_fetch_array($result))
{
echo $row['title']. " - ". $row['article'];
echo "<br />";
}
}
else
{
echo "No Articles";
}
}
?>
I know this is more than likely starting me in the face but for the last 3 hours ive been trying to get this to work to no avail!
Any help would be appreciated.