select and print everything from a table except 1
i have a question. i have a table named news that has rows such as;
news_id , timestamp , log开发者_运维技巧in_id , headline,
i would like to echo all the headlines and timestamps that go with them except for login_id = 1
How can i achieve this?
i would like to do something like
select timestamp, headline, login_id;
echo everything exept login_id = 1;
printed on a table?
thank you for reading.
<?php
$query=mysql_query("SELECT timestamp, headline, login_id FROM news WHERE login_id <> 1");
while ($row=mysql_fetch_assoc($query)){
echo $row['timestamp'].' '.$row['headline'].' '.$row['login_id'];
}
?>
SELECT timestamp, headline, login_id FROM my_table WHERE login_id != 1;
The sql query you would use is
SELECT timestamp
, headline
, login_id
FROM news
WHERE login_id <> 1
$reuslt = mysql_query('SELECT timestamp, headline, login_id FROM news WHERE login_id <> 1');
echo '<table>';
while($row = mysql_fetch_assoc($result))
{
echo "<tr><td>".$row['timestamp']."</td><td>".$row['headline']."</td></tr>";
}
echo "</table>";
精彩评论