Hello,
My actual question is how would I go about creating a autocomplete dropdown off tags that will refer to a particular page, like on this site.
I already have a autocomlete dropdown and it looks in the db field for a word starting with something% (wildcard),but that is just one word
What if you would have like 5 tags, comma seperated like tag1, tag2, tag3, etc, in one field that will refer to one particular page. How would you start the query looking for tags starting with the letter F for example, extract them and put them in the dropdownlist and also get the url from the url field at the same time ofcourse.
and also by typing two or more tags, the results should get more precise
These are just my own thoughts, I have not figured out what would be the best way to acomplish this.
EDIT I used the information below to cook something up like this. I still have to make a page with the search results, so this is by long not ready.
CREATE TABLE tag_targets (
tag_target_id MEDIUMINT UNSIGNED NOT NULL auto_increment,
tag_target_naam varchar(30) NOT NULL,
tag_target_url varchar(255) NOT NULL,
PRIMARY KEY (tag_target_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE tags (
tag_id MEDIUMINT UNSIGNED NOT NULL auto_increment,
tag varchar(30) NOT NULL,
PRIMARY KEY (tag_id),
UNIQUE KEY tag (tag)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE target_tag (
tag_target_id MEDIUMINT UNSIGNED NOT NULL,
tag_id MEDIUMINT UNSIGNED NOT NULL,
FOREIGN KEY (tag_target_id) REFERENCES tag_targets(tag_target_id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
$q = "SELECT t1.tag_target_url,t2.tag FROM tag_targets AS t1,tags AS t2, target_tag AS t3 WHERE t1.tag_target_id = t3.tag_target_id AND t2.tag_id = t3.tag_id AND tag LIKE '$queryString%' LIMIT 10";
thanks, Richard