This works
Code: Select all
<?php
$q = strtolower( $_GET["q"] );
if (!$q) return;
$dbhost = "localhost"; // Database Host
$dbuser = "root"; // User
$dbpass = ""; // Password
$dbname = "shop"; // Name of Database
mysql_connect( $dbhost, $dbuser, $dbpass ) or die( mysql_error() );
mysql_select_db( $dbname ) or die( mysql_error() );
// Replace "TABLE_NAME" below with the table you'd like to extract data from
$data = mysql_query( "SELECT * FROM tbl_products" )
or die( mysql_error() );
// Replace "COLUMN_ONE" below with the column you'd like to search through
// In between the if/then statement, you may present a string of text
// you'd like to appear in the textbox.
while( $row = mysql_fetch_array( $data )){
if ( strpos( strtolower($row['product_Description'] ), $q ) !== false ) {
echo $row['product_Name'] . "\n";
}
}
?>
Code: Select all
<?php
$q = strtolower( $_GET["q"] );
if (!$q) return;
$dbhost = "localhost"; // Database Host
$dbuser = "root"; // User
$dbpass = ""; // Password
$dbname = "shop"; // Name of Database
mysql_connect( $dbhost, $dbuser, $dbpass ) or die( mysql_error() );
mysql_select_db( $dbname ) or die( mysql_error() );
// Replace "TABLE_NAME" below with the table you'd like to extract data from
$data = mysql_query( "SELECT * FROM tbl_products" )
or die( mysql_error() );
// Replace "COLUMN_ONE" below with the column you'd like to search through
// In between the if/then statement, you may present a string of text
// you'd like to appear in the textbox.
while( $row = mysql_fetch_array( $data )){
if ( strpos( strtolower($row['product_Description']) || strtolower($row['product_Name']) , $q ) !== false ) {
echo $row['product_Name'] . "\n";
}
}
?>Cheers
Kevin