My goal is to keep it dynamic, so if i'd add one variable to the array of columns we must load, it would also display that one. But it is not working.
It currently displays this:

Can anyone help me?
The code:
/*START------TABLE WITH USERDATA*/
$table = 'mytable';
$vars = array(
1 => 'user', 2 => 'runtime', 3 => 'created', 4 => 'xpgained', 5 =>
'profit'
);
echo "<table border='1'><tr>";
/*here we make the 'header' of the table*/
$length = sizeof($vars);
for ($i = 1; $i < $length + 1; $i ++) {
echo "<td>$vars[$i]</td>";
}
echo "</tr>";
/*and here the table itself*/
$first = true;
$imploded = implode(",", $vars);
$sql = mysql_query("SELECT $imploded FROM $table");
while ($row = mysql_fetch_array($sql)) {
if ($first == true) {
for ($i = 1; $i < $length + 1; $i ++) {
$string .="<td>".$row[$vars
[$i]]."</td>";
}
}
echo "<tr>";
echo $string;
echo "</tr>";
$first = false;
}
echo "</table>";
/*END------TABLE WITH USERDATA*/
Edited by dunnkers, 15 July 2010 - 12:29 PM.


Sign In
Create Account


Back to top









