Jump to content
Killersites Forums

CREATING SEARCH FORM IN DREAMWEAVER


Jarel101
 Share

Recommended Posts

Hi, I'm creating a image gallery and I'm about 90% complete. One of my final objectives is to create a keyword search for my image gallery. I have 4 fields in my DB, (id,image,description,keywords) I want to be able to enter keywords into a search and the images with there descriptions show up. I've been searching the internet and Youtube and I can't find any tutorials that I fully comprehend. I already have the keywords in my mysql. After inserting the form, text field and search button I don't really know the next step.

 

 

For this project I'm using Dreamweaver Cs5, I'm not really an experienced coder I rely heavily on dreamweaver for my code, I just make minor tweaks. So if anyone has an answer to my problem please break down and simplify your answer I'm still a beginner. Thanks in advance.

 

ps

 

If anyone knows of any other video tutorials of this process please inform me, it would be greatly appreciated, thank you.

Link to comment
Share on other sites

I believe you are looking for the LIKE method in mysql. http://www.mysqltutorial.org/sql-like-mysql.aspx

 

Ok say you have a first and last name in the database.

 


id     first_name      last_name

1      John            Smith
2      Joe             Blow
3      Samantha        Beth

 

Now in order to search you can use this:

 

"SELECT first_name, last_name FROM users LIKE 'J%'"

 

and that will return 2 rows. Since there are 2 names that start with J and this could be first or last name.

 

The % tells mysql which way to search, after the letter J% is searching right, before the letter %J searches left and %J% will search both.

 

"SELECT first_name, last_name FROM users LIKE '%th'" 

 

will return the names that end in 'th'.

 

Your form would look like this:

 


<form method="post" action="somepage.php">
<input type="text" name="search" size="20" />
<input type="submit" name="submit" value="Search" />
</form>

PHP:

name="search" would be $_POST['search'] <-- holds the value that was inputted into the text field.

name="submit" would be $_POST['submit'] <-- you can do a check to see if the button was clicked.

if(isset($_POST['submit']) && isset($_POST['search'])) {

   // search the database here

}
else {

   // either $_POST['search'] or $_POST['submit'] was not set.

}

 

Hopefully this clears it up for you :).

Edited by Archadian
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...