Scusatemi ma non ne vengo fuori: ho fatto un po' di prove arrampicandomi sugli specchi, ma non ci arrivo proprio.
Nel DB dove vengono inseriti gli articoli vi è un solo campo data.
Per creare la barra di navigazione tra i mesi dell'anno ho utilizzato questo codice:
codice:
if (!isset($month) || $month == "" || $month > 12 || $month < 1)
{
$month = date("m");
}
if (!isset($year) || $year == "" || $year < 1972 || $year > 2036)
{
$year = date("Y");
}
$timestamp = mktime(0, 0, 0, $month, 1, $year);
$current = date("F Y", $timestamp);
if ($month < 2)
{
$prevmonth = 12;
$prevyear = $year - 1;
}
else
{
$prevmonth = $month - 1;
$prevyear = $year;
}
if ($month > 11)
{
$nextmonth = 1;
$nextyear = $year + 1;
}
else
{
$nextmonth = $month + 1;
$nextyear = $year;
}
$first = date("w", mktime(0, 0, 0, $month, 1, $year));
$lastday = 28;
for ($i=$lastday;$i<32;$i++)
{
if (checkdate($month, $i, $year))
{
$lastday = $i;
}
}
Mentre la query per estrarre i dati dal DB è:
codice:
$numero="SELECT envo_newsstand.newsid, date_format(envo_newsstand.data, '%d/%m/%Y') as data_it, envo_newsstand.topicname, envo_newsstand.title, envo_newsstand.author, envo_newsstand.descr, envo_newsstand.reviewname, envo_newsstand.issue, envo_newsstand.posted, envo_newsstand_rev.reviewimage, envo_newsstand_rev.link FROM envo_newsstand, envo_newsstand_rev WHERE envo_newsstand.reviewname = envo_newsstand_rev.reviewname ORDER BY envo_newsstand.newsid DESC";
La barra di navigazione funziona, ma con questa query ovviamente non mi vengono restituiti solo i dati relativi al mese voluto, ma tutti i dati inseriti nel database. Il mio problema quindi è condizionare l'estrazione dei dati dal DB in base alla data.
E qui mi perdo: come selezionare i dati in bas al solo mese? :master: