Re: Query String



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
.



Relevant Pages

  • Re: Query String
    ... | I need a query to firstly retrieve the latest 10 news articles by ... | To prioritise the news articles to view those with images first, ... timestamp is a database datatype. ...
    (comp.lang.php)
  • Re: Query String
    ... I need a query to firstly retrieve the latest 10 news articles by ... To prioritise the news articles to view those with images first, ... ORDER BY timestamp DESC AND image IN ... this is a simple PHP syntax thingie. ...
    (comp.lang.php)
  • Re: Query String
    ... I need a query to firstly retrieve the latest 10 news articles by ... To prioritise the news articles to view those with images first, ... $query = ("SELECT image, newsid, title, headline, timestamp FROM news ... And if you think it's PHP - please show me where the PHP manual defines the syntax of the SELECT statement. ...
    (comp.lang.php)
  • RE: Need to be able segregate units run in excel sheet using time.
    ... It may be possible - using the timestamp as I ... you add the time stamp at the time the query was run. ... > I don't see a way around this, unless there is more to the database than I ... > the type of situation I describe above better than you can in Excel. ...
    (microsoft.public.excel.programming)
  • Re: Accessing a paradox table from a C# application...
    ... SELECT TOP 1 * FROM ModelSer ORDER BY Timestamp ... How much faster is the query if you strip off the PX? ... The ODBC driver that I am using is the Microsoft Paradox ...
    (comp.databases.paradox)