All pastes #941598 Raw Edit

Mine

public text v1 · immutable
·published 2008-03-13 20:27 UTC
rendered paste body
<html>
<head>
<title>ROBOT9000 Test Results</title>
</head>
<body>
<?php 
$link = mysql_connect('localhost', 'andrew', 'excellent')
	or die('could not connect' . mysql_error());

mysql_select_db('ROBOT9000') 
	or die('could not select db');

$query0 = 'SELECT nick, total_bans FROM `users` ORDER BY total_bans DESC LIMIT 10';
$query1 = 'SELECT nick, timeout_power FROM `users` ORDER BY timeout_power DESC LIMIT 10';
$query2 = 'SELECT nick, banned_until FROM `users` ORDER BY banned_until DESC LIMIT 10';
$query3 = 'SELECT nick, word_count FROM `users` ORDER BY word_count DESC LIMIT 15';
$query4 = 'SELECT nick, lines_talked FROM `users` ORDER BY lines_talked DESC LIMIT 10';
$query5 = 'SELECT * FROM `lines` ORDER BY id DESC LIMIT 15';

$result0 = mysql_query($query0) 
	or die('Query 0 failed: ' . mysql_error());
$result1 = mysql_query($query1)
        or die('Query 1 failed: ' . mysql_error());
$result2 = mysql_query($query2)
        or die('Query 2 failed: ' . mysql_error());
$result3 = mysql_query($query3)
        or die('Query 3 failed: ' . mysql_error());
$result4 = mysql_query($query4)
        or die('Query 4 failed: ' . mysql_error());
$result5 = mysql_query($query5)
        or die('Query 5 failed: ' . mysql_error());
?>

<table><tr><td>

<table border='3'>
<tr>
	<td>Rank</td>
	<td width='210'>Nick</td>
	<td width='95'>Word count</td>
</tr>
<?php
$counter = 1;
while ($line = mysql_fetch_array($result3, MYSQL_ASSOC)) {
   echo "<tr>\n";
   echo "\t<td>$counter</td>\n";
   $counter++;
   foreach ($line as $col_value) {
      echo "\t\t<td>$col_value</td>\n";
   }
   echo "\t</tr>\n";
}
echo "</table>\n";
mysql_free_result($result3);
?>

</td><td colspan='3'>

<table border='3'>
<tr>
	<td>Unique ID</td>
	<td width=1150>Last messages (parsed)</td>
</tr>
<?php
while ($row = mysql_fetch_row($result5)) {
	echo "<tr>\n";
	echo "\t\t<td>$row[0]</td>\n";
	if (strlen($row[1]) > 170) {
		$sub = substr($row[1],0,164);
		echo "\t\t<td>$sub...</td>\n";
	}
	else {
		$sub = substr($row[1],0,167);
		echo "\t\t<td>$sub</td>\n";
		echo "\t</tr>\n";
	}
}
echo "</table>\n";
mysql_free_result($result5);
?>

</td></tr><tr><td>

<table border='3'>
<tr>
<td>Rank</td>
<td width='210'>Nick</td>
<td width='95'>Lines wrote</td>
</tr>
<?php
$counter = 1;
while ($line = mysql_fetch_array($result4, MYSQL_ASSOC)) {
   echo "\t<tr>\n";
   echo "\t<td>$counter</td>\n";
   $counter++;
   foreach ($line as $col_value) {
      echo "\t\t<td>$col_value</td>\n";
   }
   echo "\t</tr>\n";
}
echo "</table>\n";
mysql_free_result($result4);
mysql_close($link);
?>

</td><td>

<table border='3'>
<tr>
<td>Rank</td>
<td width='210'>Nick</td>
<td>Total bans</td>
</tr>
<?php
$counter = 1;
while ($line = mysql_fetch_array($result0, MYSQL_ASSOC)) {
   echo "\t<tr>\n";
   echo "\t<td>$counter</td>\n";
   $counter++;
   foreach ($line as $col_value) {
      echo "\t\t<td>$col_value</td>\n";
   }
   echo "\t</tr>\n";
}
echo "</table>\n";
mysql_free_result($result0);
?>

</td><td>

<table border='3'>
<tr>
<td>Rank</td>
<td width='210'>Nick</td>
<td>Timout Power</td>
</tr>
<?php
$counter = 1;
while($line = mysql_fetch_array($result1, MYSQL_ASSOC)) {
   echo "\t<tr>\n";
   echo "\t<td>$counter</td>\n";
   $counter++;
   foreach ($line as $col_value) {
      echo "\t\t<td>$col_value</td>\n";
   }
   echo "\t</tr>\n";
}
echo "</table>\n";
mysql_free_result($result1);
?>

</td><td>

<table border='3'>
<tr>
<td>Rank</td>
<td width='210'>Nick</td>
<td width='240' align='right'>Banned until [GMT]</td>
</tr>
<?php
$counter = 1;
while ($row = mysql_fetch_row($result2)) {
   echo "\t<tr>\n";
   echo "\t<td>$counter</td>\n";
   $counter++;
	 echo "\t\t<td>$row[0]</td>\n";
	 if ($row[1] == 0) {
	 	echo "\t\t<td align='right'>0</td>\n";
		}
	 else {
	 $st = $row[1];
	 $dt = new DateTime("@$st");
	 $string = date_format($dt, "F j Y, g:i a");
	 echo "\t\t<td align='right'>$string</td>\n";
	 }
   echo "\t</tr>\n";
}
echo "</table>\n";
mysql_free_result($result2);
?>

</td></tr></table>

</body>
</html>