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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.