Jump to content

[SOLVED] Ignore ID 1


PGTibs

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.