i want to build a three level keywords system for every entry. As suggested i've created one table (ctypes) for categories' information and one (categories) for the relation table with entry.
CREATE TABLE ctypes (
cat_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
cat_name VARCHAR(20) NOT NULL,
cat_level INT UNSIGNED NOT NULL,
parent_id INT UNSIGNED,
PRIMARY KEY (cat_id),
UNIQUE (cat_name)
);
CREATE TABLE categories (
entry_id INT UNSIGNED NOT NULL,
cat_ids VARCHAR(100) NOT NULL,
UNIQUE (entry_id)
);
then i've already build a form to collect the keywords information by checkboxs.
<form action="add_category.php" method="post">
<table>
<tr>
<td><b>Level 1(A,B,C)</b></td>
<td><b>Level 2(Aa,Ab,Ac)</b></td>
<td><b>Level 3(Aa1,Aa2,Aa3)</b></td>
</tr>
<tr>
<td>A</td>
<td>Aa</td>
<td><input type="checkbox" name="cat[]" value="5" />Aa1<td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="checkbox" name="cat[]" value="6" />Aa2</td>
</tr>
<tr>
<td></td>
<td>Ab</td>
<td><input type="checkbox" name="cat[]" value="7" />Ab1</td>
</tr>
...
</table>
<input type="hidden" name="eid" value="1" />
<input type="submit" name="submit" value="submit" />
</form>
And i've create a relation table for the entry_id and cat_id, how to save the $cat[] data to the table?
Then, how to handle this edit(add/remove) the keywords for every entry, and how to search the entry by (1st,2nd,3rd keywords)?