PDA

View Full Version : [Share] Code Top Tỉ Phú



xinemdung
05-10-14, 10:33 AM
Em mới làm xong xin đừng chém =))


<html><head><title>Top Tỉ Phú</title></head><body>
<?PHP
$db_host = 'localhost';
$db_user = 'root';
$db_pwd = ' ';

$table = 'users';

IF (!MYSQL_CONNECT($db_host, $db_user, $db_pwd))
DIE("Can't connect to database");

IF (!MYSQL_SELECT_DB($freemys2_mysql)) DIE("Can't select database");

// sending query
$result = "SELECT * FROM `accounts` ORDER BY `accounts`.`Money` DESC LIMIT 7, 30 ";
IF (!$result) {
DIE("Query to show fields from table failed");
}

$fields_num = MYSQL_NUM_FIELDS($result);

ECHO "<h1>Users: {$table}</h1>";
ECHO "<table border='1'><tr>";
// printing table headers
FOR($i=0; $i<$fields_num; $i++)
{
$field = MYSQL_FETCH_FIELD($result);
ECHO "<td>{$field->Kills}</td>";
}
ECHO "</tr>\n";
// printing table rows
WHILE($row = MYSQL_FETCH_ROW($result))
{
ECHO "<tr>";

// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
FOREACH($row AS $cell)
ECHO "<td>$cell</td>";

ECHO "</tr>\n";
}
MYSQL_FREE_RESULT($result);

?>
</body></html>