DarkHavn Posted September 2, 2006 Share Posted September 2, 2006 Hey i was just wondering, i'm building a search engine type script.I was wondering, i have just build a section of the page, where users can upload an image, descriptions about the image etc and they have a section to enter keywords for that image.Say up to 200 odd keywords per image.Now i have a seperate page, the search page, so if someone searched for the word "Watch" it would search through the keyword section of the database for the word "watch" and bring back the proper results.My question is, would i use "SELECT * FROM" or is there a proper method if searching the database just for one word, when there is another 199 words with it also?If you get my drift?please anyone? Quote Link to comment Share on other sites More sharing options...
DarkHavn Posted September 2, 2006 Author Share Posted September 2, 2006 awww come one guys/girls don't be like that :( Quote Link to comment Share on other sites More sharing options...
Barand Posted September 2, 2006 Share Posted September 2, 2006 Your database should look something like this[pre]image keyword---------- -----------imageID ----< imageIDimage_desc keyword[/pre]So you might have this in the image table[pre] imageID | image_desc---------|--------------------------- 1 | Moonrise over Yosemite 2 | My family [/pre] and in the keyword table[pre]imageID | keyword---------|----------------- 1 | moonrise 1 | landscape 1 | yosemite 1 | ansel 1 | adams 2 | family 2 | personal 2 | people [/pre] So if you want to search for images with keyword "landscape"[code]<?php$search = "landscape";$sql = "SELECT i.imageID, i.image_desc FROM image i INNER JOIN keyword k ON i.imageID = k.imageID WHERE k.keyword = '$search' ";?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.