Probably A Simple Answer

Codes here !

Moderators: macek, egami, gesf

Post Reply
DoppyNL

Re: Probably A Simple Answer

Post by DoppyNL » Thu Oct 17, 2002 10:37 pm

Code: Select all

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

DoppyNL

Post by DoppyNL » Sat Oct 19, 2002 12:24 am

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: Select all

where id = 12

, or when you want a range:

Code: Select all

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

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests