Jump to content

how to insert record from (search)


ctcp

Recommended Posts

<?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

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.

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.