ctcp Posted June 26, 2009 Share Posted June 26, 2009 <?php $results = mysql_query("SELECT * FROM crackz WHERE `option` = 'yes' and `type` = '$type' and name LIKE '%". $query ."%' ORDER BY date DESC LIMIT $page, $limit"); while ($data = mysql_fetch_array($results)) { ?> <li>[<?=$data["type"]?>] [<?=$data["date"]?>] <a href="?section=view&id=<?=$data["id"]?>&type=<?=$type?>" title="<?=$data["name"]?>"><?=$data["name"]?></a> </li> <? } ?> this is my search scripot how to insert to mysql the search world .. i mean if i searching for SEX in my search form how to inserth this world (sex + $type) to mysql ? my search form is .. <form name="form1" method="get" action=""> <label> <input <?php if (!(strcmp($type,"Games"))) {echo "checked=\"checked\"";} ?> name="type" type="radio" value="Games" /> <a href="?type=Games&query=">Games</a></label> <label> <input <?php if (!(strcmp($type,"Apps"))) {echo "checked=\"checked\"";} ?> type="radio" name="type" value="Apps" /> <a href="?type=Apps&query=">Apps</a> <label> <input <?php if (!(strcmp($type,"Movies"))) {echo "checked=\"checked\"";} ?> type="radio" name="type" value="Movies" /> <a href="?type=Movies&query=">Movies</a> </label> <label> <input <?php if (!(strcmp($type,"TV"))) {echo "checked=\"checked\"";} ?> type="radio" name="type" value="TV" /> <a href="?type=TV&query=">TV</a></label> <label> <input <?php if (!(strcmp($type,"Music"))) {echo "checked=\"checked\"";} ?> type="radio" name="type" value="Music" /> <a href="?type=Music&query=">Music</a></label> <label> <input <?php if (!(strcmp($type,"eBooks"))) {echo "checked=\"checked\"";} ?> type="radio" name="type" value="eBooks" /> <a href="?type=eBooks&query=">eBooks</a></label> <label> <input <?php if (!(strcmp($type,"Porn"))) {echo "checked=\"checked\"";} ?> type="radio" name="type" value="Porn" /> <a href="?type=Porn&query=">Porn</a></label> <label> <input <?php if (!(strcmp($type,"Other"))) {echo "checked=\"checked\"";} ?> type="radio" name="type" value="Other" /> <a href="?type=Other&query=">Other</a></label> <label> <br /> <input name="query" type="text" id="query" size="50"> </label> <label></label> <label> <input type="submit" value="Search"> </label> <label></label> </form> Link to comment https://forums.phpfreaks.com/topic/163769-how-to-insert-record-from-search/ Share on other sites More sharing options...
ctcp Posted June 26, 2009 Author Share Posted June 26, 2009 bump! Link to comment https://forums.phpfreaks.com/topic/163769-how-to-insert-record-from-search/#findComment-864171 Share on other sites More sharing options...
gevans Posted June 26, 2009 Share Posted June 26, 2009 I'm not sure I fully understand what you're trying to do. Are you just looking at doing a basic insert? Link to comment https://forums.phpfreaks.com/topic/163769-how-to-insert-record-from-search/#findComment-864172 Share on other sites More sharing options...
ctcp Posted June 26, 2009 Author Share Posted June 26, 2009 look i got Search field i type Games or help or dude and click search how to insert this world (Games or help or dude) to mysql database i whana see what my users searching ... and thank you mate :-) you help me alot .. Link to comment https://forums.phpfreaks.com/topic/163769-how-to-insert-record-from-search/#findComment-864173 Share on other sites More sharing options...
gevans Posted June 26, 2009 Share Posted June 26, 2009 First you'll need a table in your db, something like `search_terms`, than add some fields; `term`, `timestamp`, `ip` whatever you want to track. Then you can add it above your current search query; <?php $sql = "INSERT INTO `search_terms` (`term`, `timestamp`, `ip`) VALUES ('$query', $timestamp, '$ip')"; mysql_query($sql); $results = mysql_query("SELECT * FROM crackz WHERE `option` = 'yes' and `type` = '$type' and name LIKE '%". $query ."%' ORDER BY date DESC LIMIT $page, $limit"); while ($data = mysql_fetch_array($results)) { ?> <li>[<?=$data["type"]?>] [<?=$data["date"]?>] <a href="?section=view&id=<?=$data["id"]?>&type=<?=$type?>" title="<?=$data["name"]?>"><?=$data["name"]?></a> </li> <?php } ?> Obviously you'd have to assign the timestamp and ip values to the variables I put in, they're just examples. Link to comment https://forums.phpfreaks.com/topic/163769-how-to-insert-record-from-search/#findComment-864176 Share on other sites More sharing options...
ctcp Posted June 26, 2009 Author Share Posted June 26, 2009 thank you mate for your help .. i upload this code to my test page but i see db tables is empty .. nothink happen .. Link to comment https://forums.phpfreaks.com/topic/163769-how-to-insert-record-from-search/#findComment-864192 Share on other sites More sharing options...
ctcp Posted June 26, 2009 Author Share Posted June 26, 2009 $sql = "INSERT INTO `search_terms` (`term`) VALUES ('$query')"; mysql_query($sql) or die ($sql); i try and this work fine thanks i will fix IP and time too :-) Link to comment https://forums.phpfreaks.com/topic/163769-how-to-insert-record-from-search/#findComment-864200 Share on other sites More sharing options...
ctcp Posted June 26, 2009 Author Share Posted June 26, 2009 i got 5 culms in my db if NAME is null how don't show this record ? in result.php ? `name` = ' ? ' Link to comment https://forums.phpfreaks.com/topic/163769-how-to-insert-record-from-search/#findComment-864244 Share on other sites More sharing options...
gevans Posted June 27, 2009 Share Posted June 27, 2009 test the query first, if(is_null($query)) Link to comment https://forums.phpfreaks.com/topic/163769-how-to-insert-record-from-search/#findComment-864626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.