Jump to content

How to query some of a field? Let me explain what I mean...


jordz

Recommended Posts

The best example of this would be a database full of plane models and types. For example

 

In the field planemodel I have:

747-400

747-4AC

747-450

747-345

747-231

747-492

 

How would I query the database just to return everything where it has 747-4 or 747-2 in it?

 

Thanks a lot :),

Jordan

Thanks! :)

 

Now Ive just had a thought, If someone were to enter into a search box 737-300, is there some way to query that and return results 737-321 etc with out having to say:

 

if($search == '737-300'){

do this and have lots of code for each search to parse out the crap.

}

 

Thanks in advance.

 

Jordan :)

 

 

$result = "SELECT * FROM pf_planes WHERE model LIKE '%$input%'"; // ORDER by id DESC
while($res=mysql_fetch_array($result))
{
//// ACTUAL RESULTS
}
$related = substr($input,0,5);
$relatedresult = "SELECT * FROM pf_planes WHERE model LIKE '%$related%'"; // ORDER by id DESC
while($res=mysql_fetch_array($relatedresult))
{
//// RELATED RESULTS
}

;)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.