Hejsa.
Jeg har lavet dette her:
- <div id="content">
-
- <div id="content_text">
- <?php
- include("config.php");
- include("query_class.php");
- $sql = "SELECT * FROM server";
- $query = mysql_query($sql);
-
- $userver_list = array();
- while($row_s=mysql_fetch_assoc($query)) {
- $server_list[] = $row_s;
- $info = query_source($row_s['serveraddress_port']);
- }
- ?>
- <html>
- <body>
- Server List:
- <center>
- <table border="1">
- <tr>
- <th width="25px">ID</th>
- <th width="25px">Status</th>
- <th width="50px">Game</th>
- <th width="350px">Hostname</th>
- <th width="125px">Map</th>
- <th width="50px">Players</th>
- </tr>
- <?php foreach($server_list as $row_s): ?>
- <tr>
- <td align="center"><?php echo $row_s['id']?></td>
- <td align="center"><?php echo $info['status'] ? "<img src='images/online.png' alt=''>" : "<img src='images/offline.png' alt=''>"; ?></td>
- <td align="center"><?php
- if($info['game'] == "") {
- echo "Not known";
-
- } else if($info['game'] == "cstrike") {
- echo "Counter-Strike: Source";
-
- } else if($info['game'] == "dods") {
- echo "Day of Defeat: Source";
-
- } else if($info['game'] == "left4dead") {
- echo "Left 4 Dead";
-
- } else if($info['game'] == "tf") {
- echo "Team Fortress 2";
-
- } else if($info['game'] == "garrysmod") {
- echo "GarrysMod";
-
- }else if($info['game'] == "insurgency") {
- echo "Insurgency";
-
- } else if($info['game'] == "hl2mp") {
- echo "Hl2: Death Match";
-
- } else if($info['game'] == "hl1mp") {
- echo "Hl1: Multiplayer";
-
- } else if($info['game'] == "czero") {
- echo "Counter-Strike: Condition Zero";
-
- } else if($info['game'] == "dod") {
- echo "Day of Defeat";
-
- } else if($info['game'] == "tfc") {
- echo "Team Fotress Classic";
-
- }
- ?></td>
- <td align="center"><?php echo $info['name'] ?></td>
- <td align="center"><?php echo $info['map'] ?></td>
- <td align="center"><?php echo "{$info['players']} / {$info['playersmax']}"; if($info['bots'] > 0) { echo "(" . $info['bots'] . ")"; } ?></td>
- </tr>
- <?php endforeach; ?>
- </table>
- </center>
- </div>
Så har jeg min database, den ser sådan her ud:
- CREATE TABLE IF NOT EXISTS `server`(
- `id` int(10) NOT NULL AUTO_INCREMENT,
- `serveraddress_port` varchar(25) NOT NULL,
- `rcon` varchar(35) NOT NULL,
- PRIMARY KEY(id)
- );
Problemet opstår når der er mere end én server skrevet ind. Den virker fint med en enkel. Men hvis jeg tilføjer en til, så bliver den første fjernet og skiftet ud med nummer 2 og nummer 2 bliver bare nummer 2. Hvad er der galt? (Sig til hvis jeg skal smide noget mere info op.
- Hilsen,
Magnus.