I have on my side bar links. I want when I click on each link to open each page in the same one, which is the blog.php. I tried, but I guess I'm missing something because doesn't work. I need a little help. This is my code, with the blog.php, where I have the side bar: <?php include ('mysql_connect.php'); $query = "SELECT id, title, author,post,category, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts ORDER BY date DESC"; $result = @mysql_query($query); if ($result) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $mess = stripslashes($row['post']); echo '<p class="text"><b><a href="article.php?id='.$row['id'].'">'. $row['title'].'</a></b><br />'. $row['sd'].'<br /> Category: <b>'.$row['category'].'</b><br /> Posted by: <b>'.$row['author'].'</b><br />'; echo snippet($mess, 200, true); echo "</p>"; } } else { echo 'There are no news posts to display'; } ?> </div> <div id="sidebar"> <div id="top_sidebar"> <?php $cat = $_GET['category']; $query = "SELECT id, title, author,post,category FROM news_posts WHERE category='cat'"; $result = @mysql_query($query); if ($result){ $count_items = count($result); $cat = $row['category']; echo '<a href="blog.php?cat=css">CSS</a>'; } ?> </div> </div> PHP:
I'm not sure what exactly you are trying to do, but I think the problem is here - <?php $cat = $_GET['category']; $query = "SELECT id, title, author,post,category FROM news_posts WHERE category='cat'"; $result = @mysql_query($query); if ($result){ $count_items = count($result); $cat = $row['category']; echo '<a href="blog.php?cat=css">CSS</a>'; } ?> Code (markup): This will only echo out one link multiple times (<a href="blog.php?cat=css">CSS</a>). Should it possibly be - <?php $cat = $_GET['category']; $query = "SELECT id, title, author,post,category FROM news_posts"; $result = @mysql_query($query); if ($result){ $count_items = count($result); $cat = $row['category']; echo '<a href="blog.php?cat='.urlencode($cat).'">'.$cat.'</a>'; } ?> Code (markup):