PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$id = mysql_real_escape_string($_GET['id']);
// Performing SQL query
$query = 'SELECT * FROM games WHERE category = "$id" ORDER BY id DESC';
I am trying to get the ID from the url eg. categories.php?id=action and it will query action games.
This is what I dont understand, I am trying the above code and if I echo $id it prints the id that is in the url fine, but still doesn't seem to work in the category="$id"... If I change the category to = "action" it works fine, I change it back to = $id and it doesn't, even though it is still works when I echo "$id"...
u can only use "$id" by itself when u r dealing with numbers, in this case you have a string not a number so u must soround id by single quotes like this:
category = ' ".$id." ' (be sure to remove the whitespace between ' and this ", i put them there so its more clear to view) so what u want is this: category = '".$id."'
(start ur mysql command with doubles instead of singles)
jazz090 wrote:category = ' ".$id." ' (be sure to remove the whitespace between ' and this ", i put them there so its more clear to view) so what u want is this: category = '".$id."'