So for uni im having to make a website that has a database connection. so i chose something reletively easy, a blog.
That hard part for me was doing a search, more specifcally ordering the results by relevance.
I have devised a process of giving each blog post a score based on its content, and i put all of these score in an array.
I then use asort($array, SORT_NUMERIC) to order the array highest number to lowest.
This worked find untill a friend of my searched something, and it returned results in the wrong order.
A post that got a score of 1 was above a post with a score of 4.
I dont have the ability to show you guys the code atm, so i was hoping some smart person could tell me a better php function to use to sort this array?
Alternatively, should i try and sort the arrray manually? would this give me a more reliable result?
I will be at home later, and will be able to upload the code if needs be.
Question
mikeaag
Hey,
So for uni im having to make a website that has a database connection. so i chose something reletively easy, a blog.
That hard part for me was doing a search, more specifcally ordering the results by relevance.
I have devised a process of giving each blog post a score based on its content, and i put all of these score in an array.
I then use asort($array, SORT_NUMERIC) to order the array highest number to lowest.
This worked find untill a friend of my searched something, and it returned results in the wrong order.
A post that got a score of 1 was above a post with a score of 4.
I dont have the ability to show you guys the code atm, so i was hoping some smart person could tell me a better php function to use to sort this array?
Alternatively, should i try and sort the arrray manually? would this give me a more reliable result?
I will be at home later, and will be able to upload the code if needs be.
Any help is appreciated :D
Thanks in advance
Link to comment
Share on other sites
12 answers to this question
Recommended Posts