|
Posted by Oli Filth on 11/15/05 16:00
kenoli wrote:
> I an using only one field to store the date info, which is a date type.
> Here is the format, as exported from the actual table:
>
> `date` date NOT NULL default '0000-00-00'
>
> Here is the query (The two fields accessed are date, summary):
>
> $query = "SELECT date_format(date, '%c.%e.%Y') as date, summary
> FROM tbl_news_stories ORDER BY date DESC";
> $result = mysql_query ($query);
>
> while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
>
> echo "<p>{$row['date']} - {$row['summary']}</p>";
>
Well, the fact that you're using a column name as an alias in the
SELECT clause is probably why this isn't working.
The alias "date" is overriding the field name "date" when MySQL
performs the ORDER BY instruction, hence the output strings are being
sorted rather than the original date data.
Not to mention that you're using a reserved keyword "date" as a field
name without escaping it in your query!.
--
Oli
Navigation:
[Reply to this message]
|