Originalmente inviato da
Xsescott
Grazie, anche se non so perché non riesco a far funzionare questa benedetta pagina...
Ecco che faccio:
creo la tabella
Codice:
CREATE TABLE `createdtablename` (
`id` varchar(11) NOT NULL,
`total_votes` int(11) NOT NULL default '0',
`total_value` int(11) NOT NULL default '0',
`average` float(5,2) NOT NULL default '0',
`which_id` int(11) NOT NULL default '0',
`used_ips` longtext,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=3 ;
nei files db.php e rpc.php modifico
Codice PHP:
if (($vote_sent >= 1 && $vote_sent <= $units) && ($ip == $ip_num)) { // keep votes within range
$update = "UPDATE $tableName SET total_votes='".$added."', total_value='".$sum."', used_ips='".$insertip."' WHERE id='$id_sent'";
$result = mysql_query($update);
}
in
Codice PHP:
if (($vote_sent >= 1 && $vote_sent <= $units) && ($ip == $ip_num)) { // keep votes within range
$average=$sum / $added;
$update = "UPDATE $tableName SET total_votes='".$added."', total_value='".$sum."', average='".$average."', used_ips='".$insertip."' WHERE id='$id_sent'";
$result = mysql_query($update);
}
...ma do' metto sto codice?
Codice:
mysql_query("INSERT INTO `createdtablename` (id, total_votes, total_value, average, which_id, used_ips) VALUES('Test', '0', '0', '0', '0', '') ") or die(mysql_error());
...e questo?
Codice PHP:
<?php
$conn = mysql_connect($dbhost, $dbuser, $dbpass)
or die ('Error connecting to mysql');
mysql_select_db($dbname);
$tableName="createdtablename";
$result = mysql_query("SELECT * FROM createdtablename
WHERE average > 0 ORDER BY average DESC LIMIT 0, 10")
or die(mysql_error());
echo "<table>";
// keeps getting the next row until there are no more
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['id'];
echo "</td><td>";
echo $row['average'];
echo "</td><td>";
echo $row['total_votes'];
echo "</td></tr>";
}
echo "</table>";
:-(
Sto esaurendo!