我最近一直在使用 PHP,但不太了解。
现在我正在尝试从一行中获取所有信息。这是我到目前为止所拥有的:
$server = mysql_query("SELECT * FROM servers;");
$serverFinal = mysql_fetch_row($server);
这是可行的,但是每当我在表中有超过 1 行时,它只会一直给我第一行。这是完整的代码:
<?php
include "C:/wamp/www/minebook/mysql/info.php";
$db_database = 'minebook_servers';
mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_database);
$result = mysql_fetch_array(mysql_query("SELECT COUNT(*) as count FROM servers"));
$f = 1;
while ($f <= $result['count']) {
$server = mysql_query("SELECT * FROM servers;");
$serverFinal = mysql_fetch_row($server);
$response = $status->getStatus("$serverFinal[1]", $serverFinal[2]);
if(!$response) {
echo '
<tbody>
<tr>
<td class="mname">'.$serverFinal[0].'</td>
<td class="mserver">OFFLINE</td>
<td class="mstatus">OFFLINE</td>
</tr>
</tbody>
';
} else {
echo '
<tbody>
<tr>
<td class="mname">
'.$serverFinal[0].' '.$serverFinal[1].' '.$serverFinal[2].'
</td>
<td class="mserver">
<img class="theadImage" border="0" src="/minebook/pictures/d_helmet.png" alt="Name" width="22" height="18">
'.$response['players'].'/'.$response['maxplayers'].'
<img class="theadImage" border="0" src="/minebook/pictures/grass.png" alt="Name" width="18" height="18">
'.$response['version'].'
</td>
<td class="mstatus">
ONLINE
</td>
</tr>
</tbody>
';
}
$f++;
}
?>
而且我知道我应该使用mysqli。我很快就会把它全部换掉。