Jump to content

Recommended Posts

I have an input box, where a user can type in anmy vehicle they want it checks it against one table called "cars" and brings back the relevent info, I also want it to bring back the colours for that car.

 

I have got this working, but it is very specific using "Like", so if the user searchs KA it works fine, but if they search Ford KA then it won't bring it back. A soultion around this is using %LIKE%.

 

The issue is say I have one colour perfromance blue that is available for the KA, Fiesta and Focus RS but not the Focus titanium how would I get it to search this without duplicated data. My first thought was having a field called "Model" with data in like KA Fiesta Focus RS and use the %LIKE%., but because the Focus titanium has the word focus the colour will still get pulled out.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/219183-search-tags-for-mutliple-vehicles/
Share on other sites

well a user might search for a car in the following ways, I'll use a ford fiesta TDCi titanium 1.6 litre diesel as an example.

 

Ford

Fiesta

Ford Fiesta

Titanium

Ford Fiesta Titanium

 

Currently I have 4 fields make (ford) model (fiesta titanium) extras (1.6 diesel) and search (ford fiesta TDCi titanium 1.6 litre diesel) and I'm using the %LIKE% to search all 4 fields in this manner.

 

In relation to the colours, I now have this working fine and comes back with the correct colours for each car, but I would like a more efficent search method or do you think this one would do?

 

Also to add more control I have done the following code, which works fine on firefox but doesnt on IE any suggestions on how to fix the IE??

 

Go to www.bikescarsandvans.co.uk/test.php to see it for yourself / test it.

 

Finally any suggestions on how to get it so I can limit the data to say 50 records and then the next 50 to go onto another page? I know I can limit the results with my query but cant figure out the best soultion of the top of my head.

 

Cheers

 

print "
						<form target='_self' method='POST'>
						<table class=''> 
							<tr> 
								<td>
									<input name='vehicle' type='text' id='search_name' size='16'>
									<input type='image' src='images/search.gif' alt='Search' name='submit' id='search' value='Search'/>
								</td>
							</tr>
							<tr>
								<td>
									<select name='filter' id='filter'>
										<option value='make' selected='selected'>Filter By</option>
										<option value='make'>Vehicle Manufacture</option>
										<option value='model'>Vehicle Model</option>
										<option value='our_price'>Price</option>
										<option value='delivery_time'>Delivery Time</option>
									</select>
								</td>
							</tr>
							<tr>
								<td>
									<input type='radio' name='direction' value='ASC' checked/>Ascending 
									<input type='radio' name='direction' value='DESC' />Descending

								</td>
							</tr>	
		    			</form>
				      ";
				include "connections/dbconnect.php";

				if(isset($_POST['submit'])) 
				{	
					$vehicle = $_POST['vehicle'];
					$filter = $_POST['filter']; 
					$direction = $_POST['direction']; 
				}
				else
				{
					$filter = "make"; 
					$direction = "ASC"; 
				}  
				//$manfactures = "Ford";
				$car_query = " SELECT * FROM cars WHERE model LIKE '%$vehicle%' OR make LIKE '%$vehicle%' OR model_details LIKE '%$vehicle%' OR search LIKE '%$vehicle%' ORDER BY $filter $direction ";	

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.