Skip to content

Instantly share code, notes, and snippets.

@Motoma
Created March 9, 2011 14:36
Show Gist options
  • Save Motoma/862284 to your computer and use it in GitHub Desktop.
Save Motoma/862284 to your computer and use it in GitHub Desktop.
<?php
// Our Database Class
include("lib/database.php");
$db = new Database(); // Instantiate our Database Class
$resArr = $db->query("SELECT * FROM users WHERE userid != 1"); // Query!
// $resArr is now an associative array containing the entire result set
// of the SQL query. We can now use and abuse this data as necessay.
// In this hypothetical situation, I am returing all of the users in
// my table except the Administrator
echo '<table><tr><th>UserID</th><th>UserName</th>';
echo '<th>RealName</th><th>Homepage</th></tr>';
foreach($resArr as $user)
{
echo '<tr><td>'.$user['userid'].'</td><td>'.$user['username'].'</td>';
echo '<td>'.$user['realname'].'</td><td>'.$user['homepage'].'</td></tr>';
}
echo "</table>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment