I’ve database table with the following pageid’s 1,2,3,4,5,6,7,8 –> will added more.
and i’m using
$sql ="select * from pages order by pageid";
$result= mysql_query($sql);
while($page= mysql_fetch_array($result)){
echo "$page[pagetitle]";
}
Now i want to select all except pageid=4 ! so that it won’t show the page title that have pageid = 4 and show the others 1,2,3,5,6 —> and any other added.
How to say select all except !
Simply add a
WHEREclauseWHERE pageid <> 4:Or replace with a PHP variable to make it dynamic:
If you have multiple pageids to exclude, use a
NOT IN()clause:Update:
Since this answer has more recently had some attention, it is advisable to use prepared statements and parameterize the variables instead of variables directly in the query, particularly if the variables are the result of any user input.