Probably A Simple Answer

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
Code:
if ($id == "") 
{$id = '%';}
You find out here that id is not supplied to the script.
You give it a value so that any value in the database will be returned.
You could also give it some default value or give an error message and exit you're script.

Greetz Daan
 
LIKE "%" will allow ANY value, so if ID is not present it will allow any value.
You could check if ID is supplied to you're script and if it is not remove the %%.
LIKE is used for string-comparison.

Also, if you're trying to select a specific item you could better use:
Code:
where id = 12
, or when you want a range:
Code:
where id > 12 and id <40
It will execute faster.
The speed will not really be noticed on small tables, but the moment they get much bigger you'll notice the difference.

Greetz Daan
 
Back
Top