Boxerman Posted February 27, 2010 Share Posted February 27, 2010 Hi guys, How would i store the data of what has been searched? so say google search bar, you type phpfreaks and i want it to store on the database for say 30 days... how would i go about doing this? Link to comment https://forums.phpfreaks.com/topic/193574-selecting-searched-data/ Share on other sites More sharing options...
visualazza Posted February 27, 2010 Share Posted February 27, 2010 i am only a beginner to php but i would suggest doing the following: very simple and untested some placement is wrong but the basis is there. <form name=input action=search.php method=POST> <input type=text name=q> <input type=submit name=submit value=Search> </form> <?php $q = $_POST['q']; //Include database connection details require_once ('config.php'); //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if (!$db) { die("Unable to select database"); } $qry2 = "INSERT INTO table (column) VALUES ('$q')"; $result2 = mysql_query($qry2) or die(mysql_error()); $qry2 = "SELECT * FROM table WHERE column LIKE '%$q%'"; $row = mysql_fetch_array(mysql_query($qry)); $result2 = mysql_query($qry2) or die(mysql_error()); while ($row = mysql_fetch_array($result2)) { { { echo ("" . $row['column'] . ""); } } } ?> im not sure how you would go about storing it for a time period. Link to comment https://forums.phpfreaks.com/topic/193574-selecting-searched-data/#findComment-1019126 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.