frons Mortale devoto
Registrato: 08/11/07 11:31 Messaggi: 14 Residenza: Ancona
|
Inviato: 19 Dic 2007 14:22 Oggetto: |
|
|
Tabella NEWS
Codice: | CREATE TABLE `news` (
`id` int(3) NOT NULL auto_increment,
`titolo` varchar(255) default NULL,
`data` date NOT NULL default '0000-00-00',
`corpo` varchar(255) default NULL,
`link` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ; |
E query su essa e ho fatto in modo di farmi generare delle variabili in base agli indici di $news["data"] (non so bene la terminologia):
Codice: |
$query1 = "SELECT * FROM news ORDER BY id DESC";
$risultato1 = mysql_query($query1) or die("");
while ($news = mysql_fetch_array($risultato1, MYSQL_ASSOC)) {
$data_news = $news["data"];
$anno = $data_news[0].$data_news[1].$data_news[2].$data_news[3];
$mese = $data_news[5].$data_news[6];
$giorno = $data_news[8].$data_news[9];
$data_news = mktime(0,0,0,$mese,$giorno,$anno); |
Così facendo mi è bastato fare solamente un print
Codice: | <?php print date("d/m/Y", $data_news)?> |
ed eventualmente avevo già subito a disposizione una variabile $anno se, per ipotesi, avessi voluto riportare solamente l'anno, invece di tutta la data per esteso. Problemi non me ha dati, errori nemmeno, magari sembra un po' incasinato però funziona... |
|