|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Advanced search PHP and MySQL problem
I want to order the records displayed in a search by there relevance. I have made a formula but every time I enter a PHP function in the query string no records are returned.
I have tried something like: select id, nume, vizualizari, url, descriere, categorie, subcategorie, limba, subtr_count(url,"word1")*3 +subtr_count(nume,"word1")*2 + subtr_count(descriere,"word1") + subtr_count(url,"word2")*3 +subtr_count(nume,"word2")*2 + subtr_count(descriere,"word2") AS weight from siteuri WHERE (weight>0) ORDER BY weight desc or select id, nume, vizualizari, url, descriere, categorie, subcategorie, limba, subtr_count(url,"word1")*3 +subtr_count(nume,"word1")*2 + subtr_count(descriere,"word1") + subtr_count(url,"word2")*3 +subtr_count(nume,"word2")*2 + subtr_count(descriere,"word2") AS weight from siteuri WHERE ((nume LIKE '%word1%' OR descriere LIKE '%word1%' OR url LIKE '%word1%') AND (nume LIKE '%word2%' OR descriere LIKE '%word2%' OR url LIKE '%word2%')) ORDER BY weight desc Thank you |
|
#2
|
|||
|
|||
|
Is there any errors? It looks like you may have some errors, using a php function in the query.
Have you ever tried to use fulltext in MYSQL? look it up on the mysql site. If you do you can do your query something like this: select id, nume, vizualizari, url, descriere, categorie, subcategorie, limba, MATCH (nume,descriere.url) AGAINST ('$word1') + MATCH (nume,descriere.url) AGAINST ('$word2') AS weight from siteuri WHERE MATCH (nume,descriere.url) AGAINST ('$word1') + MATCH (nume,descriere.url) AGAINST ('$word2') and weight>0 ORDER BY weight desc |
|
#3
|
||||
|
||||
|
I know about the full text indexing in mysql but I want to give more weigh to some fields.
Thank you anyway. It seams that if I use a php function in the query no records are returned. I have seen examples saying it can be done, maybe I am missing something. |
![]() |
| Viewing: SEO Chat Forums > Other > SEO Scripts > Advanced search PHP and MySQL problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|