S A N T A Posted April 27, 2008 Share Posted April 27, 2008 Ok so i am working on a blog from scratch and so far its going good but now I'm working on an archive and i got everything working but when i click a category it is suppose to display all the entries in that category but the page stays the same? heres the code: <?php require("config.php"); require("header.php"); ?> <div id="main"> <?php if(isset($_GET['id']) == TRUE) { if(is_numeric($id) == FALSE) { $error = 1; } if($error == 1) { } else { $validcat = $_GET['id']; } } else { $validcat = 0; } $db = mysql_connect($dbhost, $dbuser); mysql_select_db($dbdatabase, $db); $sql = "SELECT * FROM categories"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { if($validcat == $row['id']) { echo "<strong>" . $row['cat'] . "</strong><br />"; $entriessql = "SELECT * FROM entries WHERE cat_id = " . $validcat . " ORDER BY dateposted DESC;"; $entriesres = mysql_query($entriessql)or die(mysql_error(). " in $sql"); $numrows_entries = mysql_num_rows($entriesres); echo "<ul>"; if($numrows_entries == 0) { echo "<li>No entries!</li>"; } else { while($entriesrow = mysql_fetch_assoc($entriesres)) { echo "<li>" . date("D jS F Y g.iA", strtotime($entriesrow['dateposted'])) . " - <a href='viewentry.php?id=" . $entriesrow['id'] . "'>" . $entriesrow['subject'] . "</a></li>"; } } echo "</ul>"; } else { echo "<a href='viewcat.php?id=" . $row['id'] . "'>" . $row['cat'] . "</a><br />"; } } require("footer.php"); ?> </div> Help NEEDED Link to comment https://forums.phpfreaks.com/topic/103191-solved-little-problem/ Share on other sites More sharing options...
MadTechie Posted April 27, 2008 Share Posted April 27, 2008 shouldn't if(is_numeric($id) == FALSE) { be if(is_numeric($_GET['id']) == FALSE) { EDIT: <?php if(isset($_GET['id']) == TRUE) { if(is_numeric($id) == FALSE) { $error = 1; } if($error == 1) { } else { $validcat = $_GET['id']; } } else { $validcat = 0; } ?> revised <?php $validcat = (!empty($_GET['id']))?(int)$_GET['id']:0; ?> Link to comment https://forums.phpfreaks.com/topic/103191-solved-little-problem/#findComment-528577 Share on other sites More sharing options...
S A N T A Posted April 27, 2008 Author Share Posted April 27, 2008 lol I'm stupid thanks for the help *SOLVED* Link to comment https://forums.phpfreaks.com/topic/103191-solved-little-problem/#findComment-528578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.