prova questo codice:
Codice PHP:
<?
$Database = '';
$DbId = '';
$DbPassword = '';
$HOST = 'localhost';
$link = @mysql_pconnect($HOST, $DbId, $DbPassword);#This can't be closed by mysql_close
mysql_select_db ($Database, $link);
if (!$link) {
die('Not connected : ' . mysql_error());
}
function dbclose($link) {
if ($link) {
@mysql_close($link);
}
}
function execute($query, $error=0){
global $link;
$sth = @mysql_query ($query, $link);
if ($error == 1 && mysql_error($link)){
print "<br> $query <br> ". mysql_error($link);
return 0;
}
return $sth;
}
function num_of_rows($sth){
return @mysql_num_rows ($sth);
}
function fetch_array($sth, $count=0){
return @mysql_fetch_array ($sth);
}
?>
<TABLE cellpadding='3' cellspacing='1' border='0' align='center'>
<?
$query = "SELECT name, ip FROM users ORDER BY id DESC";
$sth = execute($query, 1);
if (num_of_rows($sth) > 0){
?>
<TR>
<TH>Name</TD>
<TH>Ip</TH>
</TR>
<?
while ($ref = fetch_array($sth)) {
$name = $ref['name'];
$ip = $ref['ip'];
?>
<TR>
<TD><?=$name?></TD>
<Th><?=$ip?></Th>
</TR>
<?
}
}
else{
print "<tr><TH>No Valori</th></tr>";
}
?>
</TABLE>