Jump to content

Selecting searched data


Boxerman

Recommended Posts

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.

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.