CanMan2004 Posted September 18, 2006 Share Posted September 18, 2006 HiI have a database which holds a series of numbers and letters in a field called 'data', I then have a search form which does query on this data in the database. Some sample data that is being held looks likeDDE21 7YHGBACN64 4RFVBNJ99 4CVBPOVH5 4RFJThe query I currently use is[code]$sql = "SELECT * FROM data WHERE `code` LIKE '%".$code."%' LIMIT 20";[/code]for example, ifDDE21is searched, then recordDDE21 7YHGBis returnedand if7YHGBis searched, it would also returnDDE21 7YHGBI can also search part of a code, as long as its the start of the code. As you will see by my query, I limit 20 records, but at the moment, I don't have enough records stored in the database to bring back 20 and no more and no less.What I want to do is to be able to do is to do a query and retrieve 15 records each time, no more, no less. As I dont have the amount of records to ensure I always get 15 returned, I want to be able to display (below the most matched results) the closest records found to the one which was just searched, which would then make a total of no more than 20.Can this be done with ease in php or could someone please help me out as ive been trying to figure it out all weekend and am having no job.Thank you for any help in advanceEd Quote Link to comment Share on other sites More sharing options...
Barand Posted September 18, 2006 Share Posted September 18, 2006 [quote]I want to be able to display (below the most matched results) the closest records found to the one which was just searched,[/quote]Define [b]closest[/b] Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted September 19, 2006 Author Share Posted September 19, 2006 How do you define closest? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.