Re: Query String
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Mon, 29 Dec 2008 12:27:36 -0500
ajtdds@xxxxxxx wrote:
Hey guys I tried it with the array method, and it seemed to work
thanks. Sorry for what might appear to most of you as a beginners
question.
Anyway I have one last problem.
I need a query to firstly retrieve the latest 10 news articles by
date, where I have used ORDER BY and the date field 'timestamp' with
LIMIT. So far so good..
I have then indicated in the database whether each news article has an
image included, marked by the field 'image' and options 'Yes' and
'No'.
To prioritise the news articles to view those with images first, I
have used AND image IN ('Yes', 'No') but I get 'Error in query:
$query'. Any other way to achieve the same effect??
<?php
$query = ("SELECT image, newsid, title, headline, timestamp FROM news
ORDER BY timestamp DESC AND image IN ('Yes', 'No') LIMIT 10");
$result = mysql_query($query) or die ('Error in query: $query .
' .mysql_error());
if (mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$newsid = $row['newsid']; echo $newsid;
$title = $row['title']; echo $title;
$headline = $row['headline']; echo $headline;
}
}
?>
THANKS!! Alec
This is SQL, not PHP, and as such is off-topic in this newsgroup. Please follow up your questions in comp.databases.mysql.
And if you think it's PHP - please show me where the PHP manual defines the syntax of the SELECT statement. You won't find it. But you WILL find it in the MySQL manual - because it is SQL syntax.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- References:
- Query String
- From: ajtdds
- Re: Query String
- From: FutureShock
- Re: Query String
- From: ajtrichards@xxxxxxxxxxxxxx
- Re: Query String
- From: Jerry Stuckle
- Re: Query String
- From: ajtdds
- Query String
- Prev by Date: Re: Strings, arrays and efficiency
- Next by Date: Re: Smarty syntax for require?
- Previous by thread: Re: Query String
- Next by thread: Re: Query String
- Index(es):
Relevant Pages
|