You are here: Re: PHP script SELECT FROM mysql database WHERE date « PHP Programming Language « IT news, forums, messages
Re: PHP script SELECT FROM mysql database WHERE date

Posted by Samuel on 09/30/05 09:52

In your first example you'd have to sort the data with php, and in the
second you'd have to query the database once for each date you want to
show. I'd recommend this instead;

SELECT * FROM pictures ORDER BY date

You will be able to get all the data you need in only one query. The
script would basically look like this.

<?php
//Assuming you already opened and selected the db...
$query = "SELECT * FROM pictures ORDER BY date";
$result = mysql_query ($query);

while (($number_of_items < 30) && ($row = mysql_fetch_array($result)))
{
if ($last_date != $row['date'])
print_break_between_dates_or_whatever();

print_the_data_or_whatever($row);

$last_date = $row['date'];
$number_of_items++;
}

?>

Hope I helped and all =)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация