Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 01-31-2012, 06:58 PM   #1
Join Date: Jan 2011
Posts: 41
Default Creating a search box for site

I am trying to teach myself through tutorials how to create a search box for a website for a client i have. Going through on tutorial it seems to work except i keep getting errors when i search for something on the site as if i didn't create the item in mysql database. I am not familiar with mysql or php too much can some see if there is a problem with my php? or have an ideas how i could have messed up my database set up?

the form is this:

HTML Code:
<form action="./results.php" method="get">
           <input name="input" type="text" size="30" <?php echo $_GET ['input']; ?> />
           <input type="submit" name="search" value="Search Items" />
and here is the connected php code:

PHP Code:
$terms explode(" "$input);
$query "SELECT * FROM search LIMIT ";
    foreach (
$terms as $each) {
        if (
$i == 1)
$query .= "keywords LIKE '%each%' ";
$query .= "OR keyword LIKE '%each%' ";
//Connect to Database
$query mysql_query($query);
$numrows mysql_num_rows($query);
        if (
$numrows 0) {
        while (
$row mysql_fetch_assoc($query)) {
$id $row['id'];
$title $row['title'];
$description $row['description'];
$keywords $row['keywords'];
$link $row['link'];
"<h2><a href='$link'>$title</a></h2>
"No result found for '<b>$input</b>'";
thank you for any help!
sydesign is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 02:22 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com