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? Link to comment https://forums.phpfreaks.com/topic/19466-mysql-search-php-question/ 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 :( Link to comment https://forums.phpfreaks.com/topic/19466-mysql-search-php-question/#findComment-84549 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] Link to comment https://forums.phpfreaks.com/topic/19466-mysql-search-php-question/#findComment-84764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.