function get_table table fields where row array sql SELECT fields FROM

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
function get_table( $table, $fields = "*", $where='' )
{
$row = array();
$sql = "SELECT $fields FROM ". $table . ( empty( $where ) ? '' : " WHERE $where" );
$result = mysql_query($sql);
//echo $sql.'<br />';
if (!$result) {
echo $sql.'<br />';
echo mysql_error();
die();
}
$num_results = mysql_num_rows($result);
for ($i = 0; $i < $num_results; $i++) {
$row[] = mysql_fetch_assoc($result);
}
return $row;
}