[PHP] Different dates with lmost same script

2003-02-07 Thread Miguel Brás
Hi,

I have 2 pages that shows a table contents
On one, it shows the title and date with the following script

**
?
// includes
include(../regulations/conf.php);
include(../regulations/functions.php);
// abre ligação à base de dados
$connection = mysql_connect($host, $user, $pass) or die (Erro de execução.
Informe-nos sobre a situação!);

// escolhe a base de dados
mysql_select_db($db) or die (Erro de execução. Informe-nos sobre a
situação!);

// gera e executa o pedido SQL
$query = SELECT * FROM noticias ORDER BY id DESC LIMIT 6;
$result = mysql_query($query) or die (Erro no pedido: $query.  .
mysql_error());

// se algum registo
if (mysql_num_rows($result)  0)
{
 // iterate através do conj resultados
 // print titulo dos artigos
 while($row = mysql_fetch_object($result))
 {
?
tr
td width=7% align=leftfont size=1 face=Arialimg border=0
src=images/ez1.jpg width=18 height=16/font/td
td width=7% align=left/td
td width=51% align=left font color=#808080 size=1 face=Ariala
href=http://www.ivao-pt.org/noticias/;? echo $row-titulo;
?/font/a/td
td width=35% align=left
p align=leftfont color=#808080 size=1 face=Arial ? echo
formatDate ($row-timestamp); ?/font/td
/tr
tr
td width=100% align=left colspan=4br
/td
/tr


?
 }
}

else
{
?
p align=centerfont size=1 face=Arial color=#4F547ANenhuma
notícia disponível!/font/p
?
}
// fecha ligação à base de dados
mysql_close($connection);
?

*
functions.php script

?
// format MySQL DATETIME value into a more readable string
function formatDate($val)
{
 $arr = explode(/, $val);
 return date(d/m/y, mktime(0,0,0, $arr[1], $arr[2], $arr[0]));
}
?

*

On the other one, besides showing date and title, it shows also the text,
autor and some other stuff almost with same code
The problem is that on the one where only the title and date are shown, he
gives me always the same date, no matter if i posted yesterday or today. The
date is always 30/11/02
On the more detailed page, the date is shown correctly, today's date if
posted today, yesterday's date if posted yesterday.
Any idea for that? I checked the table, and the date is correct...i don't
know what else to do

Miguel




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Different dates with lmost same script

2003-02-06 Thread Miguel Brás
Hi,

I have 2 pages that shows a table contents
On one, it shows the title and date with the following script

**
?
// includes
include(../regulations/conf.php);
include(../regulations/functions.php);
// abre ligação à base de dados
$connection = mysql_connect($host, $user, $pass) or die (Erro de execução.
Informe-nos sobre a situação!);

// escolhe a base de dados
mysql_select_db($db) or die (Erro de execução. Informe-nos sobre a
situação!);

// gera e executa o pedido SQL
$query = SELECT * FROM noticias ORDER BY id DESC LIMIT 6;
$result = mysql_query($query) or die (Erro no pedido: $query.  .
mysql_error());

// se algum registo
if (mysql_num_rows($result)  0)
{
 // iterate através do conj resultados
 // print titulo dos artigos
 while($row = mysql_fetch_object($result))
 {
?
tr
td width=7% align=leftfont size=1 face=Arialimg border=0
src=images/ez1.jpg width=18 height=16/font/td
td width=7% align=left/td
td width=51% align=left font color=#808080 size=1 face=Ariala
href=http://www.ivao-pt.org/noticias/;? echo $row-titulo;
?/font/a/td
td width=35% align=left
p align=leftfont color=#808080 size=1 face=Arial ? echo
formatDate ($row-timestamp); ?/font/td
/tr
tr
td width=100% align=left colspan=4br
/td
/tr


?
 }
}

else
{
?
p align=centerfont size=1 face=Arial color=#4F547ANenhuma
notícia disponível!/font/p
?
}
// fecha ligação à base de dados
mysql_close($connection);
?

*
functions.php script

?
// format MySQL DATETIME value into a more readable string
function formatDate($val)
{
 $arr = explode(/, $val);
 return date(d/m/y, mktime(0,0,0, $arr[1], $arr[2], $arr[0]));
}
?

*

On the other one, besides showing date and title, it shows also the text,
autor and some other stuff almost with same code
The problem is that on the one where only the title and date are shown, he
gives me always the same date, no matter if i posted yesterday or today. The
date is always 30/11/02
On the more detailed page, the date is shown correctly, today's date if
posted today, yesterday's date if posted yesterday.
Any idea for that? I checked the table, and the date is correct...i don't
know what else to do

Miguel



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php