Jump to content

[SOLVED] Loging Search Terms In Mysql?


Deanznet

Recommended Posts

Hey i have a search form on my site that searches a table in Mysql. i created another tabled called query_log with 2 columns query and results.

 

How can i make it so when someone searches it inserts their keyword into query and then inserts how many times it was search for into results.

 

so if someone searches php it inserts php then 1 into the query and results. if someone else searches php it inserts 2 into results.

 

Anyone?

Link to comment
https://forums.phpfreaks.com/topic/123595-solved-loging-search-terms-in-mysql/
Share on other sites

Thanks! But im still having a problem.

 

This works.

 

$querylog = "INSERT INTO query_log (query,results) VALUES ('$search',1)"; 
mysql_query($querylog) or die('Error, insert query failed');

 

But if i do

 

$querylog = "INSERT INTO query_log (query,results) VALUES ('$search',1) ON DUPLICATE KEY UPDATE SET results = results + 1)"; 
mysql_query($querylog) or die('Error, insert query failed');

 

I made my query column primary index unquie was that right?

It wont work, i get the insert query failed message.

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.