My sql Query string gives me error. I assume it has to do with the "where id= 80" par
My sql Query string gives me a error. I assume it has to do with the "where id= 80" part.
$game_info = get_table_data('games', 'id', 'ASC', 'rating', ' ', ''); // note there is a space between the second last set of single colons. So that it will trigger the function to add the where statement into the query.
// get all table data | Perform database query
function get_table_data($table, $order="id", $direction="ASC ", $column="*", $where="", $limit="") {
global $connection;
$query = "SELECT $column
FROM $table
ORDER BY $order $direction "; //must have space after $direction
if (!empty($where)) {
$query.="WHERE id = 80 "; //must have space after $limit. 80 is a example. I use it for testing the query.
if (!empty($limit)) {
$query.="LIMIT $limit ";
}
}
$table_set = mysql_query($query, $connection);
confirm_query($table_set);
return $table_set;
}
|