jjmusicpro Posted July 16, 2007 Share Posted July 16, 2007 Hi everyone! I was trying to run 2 querys in the same block. I wanted enter the zipcode they entered into a database for future analytics later, as well as spit out the results of the search. I already have the search results part working, but i cant seem to get the insert to work correctly. my table for keeping records of the zipcodes searched is: search_id (auto incrment) zipcode time_date Thanks for the help everyone! PHPFreaks ROCKS!!!!!!!! if($_SERVER['REQUEST_METHOD'] == "POST"){ require_once ('connect.php'); require_once ('opendb.php'); $zipcode = $_POST['zipcode_entered_search'];<br> $query = "INSERT INTO searched_zips VALUES ('','$zipcode','','')"; $result = mysql_query($query); $query = "SELECT * FROM zipcodes WHERE zipcode='$zipcode'"; $result = @mysql_query ($query); $count = mysql_num_rows($result); //number of results Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 <?php if (isset($_POST['zipcode_entered_search']))){ require_once 'connect.php'; require_once 'opendb.php'; $zipcode = mysql_real_escape_string($_POST['zipcode_entered_search']); $query = "INSERT INTO searched_zips VALUES ('','$zipcode','','')"; if ($result = mysql_query($query)) { $query = "SELECT * FROM zipcodes WHERE zipcode=" mysql_insertid(); if ($result = mysql_query($query)) { $count = mysql_num_rows($result); } } } ?> Quote Link to comment Share on other sites More sharing options...
jjmusicpro Posted July 16, 2007 Author Share Posted July 16, 2007 How do i get the date in there? do use date()? Also, is there a way to get any more info from the user? when they land on my page? like what keyword was used to get to my site? Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 How do i get the date in there? $query = "INSERT INTO searched_zips (zipcode,time_date) VALUES ('$zipcode', NOW())"; Also, is there a way to get any more info from the user? when they land on my page? like what keyword was used to get to my site? There is other various info available within the $_SERVER array, but no way of getting any so called keyword unless it is forwarded by the user. 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.