PGTibs Posted February 10, 2009 Share Posted February 10, 2009 I have a webpage which basically shows notes and then allows you to add more notes or remove them. However, i have added in a note with ID 1 as default which must not be removed as there are other important uses for this note. How can i make the page show every note in the database other than the note with ID 1? <? session_start(); include 'config.php'; //if the username is not set or the session username is empty or the ip does not match the session ip log them out ?> <? if($_SESSION['session_level'] == "1") { ?> <font face="verdana" size="1"><b>To Add A Note Click <a href="admin/add_notice.php">Here</a> | To Remove A Note Click <a href="admin/removenews.php">Here</a></b><Br><br> <? } ?> <font face="verdana" size="1">Welcome To The Notebook, This Is The Perfect Place For You To Store Your Precious Notes About Anything!<br></font> <br> <? $query = mysql_query("SELECT * FROM `news` ORDER BY `ID` DESC"); while($result = mysql_fetch_array($query)) { $NoticeUsername = $result["NoticeUsername"]; $NoticeMessage = $result["NoticeMessage"]; $NoticeDAT = $result["NoticeDAT"]; $NoticeTitle = $result["NoticeTitle"]; $NoticeUrgent = $result["NoticeUrgent"]; echo "<table width='100%' border='0' bgcolor='#ffccff' style='border-color: #000000; border-width: 1px; border-style: solid;'> <td colspan=2><B><font face=verdana size=1><u>$NoticeTitle</u></B></td></td> <tr> <td colspan='2'><font face=verdana size=1><li>$NoticeMessage</color></td> </tr> <tr> <td width=50%><font face=verdana size=1><b>How Urgent:</b> $NoticeUrgent</td> <td width=50%><font face=verdana size=1><b>Posted On:</b> $NoticeDAT</td> </tr> </table><br><br>"; } mysql_close($ms); ?> Link to comment https://forums.phpfreaks.com/topic/144645-solved-ignore-id-1/ Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 $query = mysql_query("SELECT * FROM `news` WHERE `ID` <> 0 ORDER BY `ID` DESC"); Link to comment https://forums.phpfreaks.com/topic/144645-solved-ignore-id-1/#findComment-759011 Share on other sites More sharing options...
PGTibs Posted February 10, 2009 Author Share Posted February 10, 2009 Big Thanks Link to comment https://forums.phpfreaks.com/topic/144645-solved-ignore-id-1/#findComment-759014 Share on other sites More sharing options...
PGTibs Posted February 10, 2009 Author Share Posted February 10, 2009 What about with this line... $result = MYSQL_QUERY("SELECT * from `news` ORDER BY `ID` DESC") If i change it too $result = MYSQL_QUERY("SELECT * from `news` <> 1 ORDER BY `ID` DESC") It makes the error underneath show... <? if($_SESSION['session_level'] == "1") { $result = MYSQL_QUERY("SELECT * from `news` ORDER BY `ID` DESC") or die("<b>An Error Has Occured</b>"); Shown: An Error Has Occured Link to comment https://forums.phpfreaks.com/topic/144645-solved-ignore-id-1/#findComment-759018 Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 You need to read up on MySQL and proper usage. This is all basic basic SQL. $result = MYSQL_QUERY("SELECT * from `news` WHERE ID <> 1 ORDER BY `ID` DESC") Note the bold area. Link to comment https://forums.phpfreaks.com/topic/144645-solved-ignore-id-1/#findComment-759027 Share on other sites More sharing options...
PGTibs Posted February 10, 2009 Author Share Posted February 10, 2009 Thanks... You need to read up on MySQL and proper usage. This is all basic basic SQL. I'll be sure too Link to comment https://forums.phpfreaks.com/topic/144645-solved-ignore-id-1/#findComment-759030 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.