Codice PHP:
<?php require_once('Connections/Conn_DB.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_Conn_DB, $Conn_DB);
$query_Ord_Class = "SELECT NS, GF, GS, PS FROM Classifica ORDER BY PS DESC";
$Ord_Class = mysql_query($query_Ord_Class, $Conn_DB) or die(mysql_error());
$row_Ord_Class = mysql_fetch_assoc($Ord_Class);
$totalRows_Ord_Class = mysql_num_rows($Ord_Class);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>classifica</title>
</head>
<body>
<table border="0">
<tr>
<td width="126">Squadra</td>
<td width="105">Gol Fatti </td>
<td width="109">Gol Subiti </td>
<td width="107"><div align="right">Punti</div></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Ord_Class['NS']; ?></td>
<td><?php echo $row_Ord_Class['GF']; ?></td>
<td><?php echo $row_Ord_Class['GS']; ?></td>
<td><div align="right"><?php echo $row_Ord_Class['PS']; ?></div></td>
</tr>
<?php } while ($row_Ord_Class = mysql_fetch_assoc($Ord_Class)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Ord_Class);
?>
questo è il dump della tabella (credo... non sono pratico):
Codice PHP:
-- Struttura della tabella `Classifica`
--
CREATE TABLE IF NOT EXISTS `Classifica` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`NS` text NOT NULL,
`GF` int(11) NOT NULL,
`GS` int(11) NOT NULL,
`PS` int(11) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=11 ;
--
-- Dump dei dati per la tabella `Classifica`
--
INSERT INTO `Classifica` (`ID`, `NS`, `GF`, `GS`, `PS`) VALUES
(1, 'AS Pollegio', 22, 11, 18),
(2, 'AC Aquila', 10, 20, 7),
(3, 'AS Onsernone', 25, 10, 22),
(4, 'AC San Vittore', 6, 30, 1),
(5, 'AS Bodio', 25, 16, 20),
(6, 'AC Sementina II', 18, 16, 15),
(7, 'AS Lusitanos', 15, 8, 15),
(8, 'AC Audax Gudo', 16, 23, 6),
(9, 'AC Codeborgo', 9, 21, 5),
(10, 'AS Verzaschesi', 26, 17, 14);