Forum Moderators: coopster
1. Files (file_id PK, file_name, file_desc, file_pages)
2. Tags (tag_id PK, tag)
3. Tags2Files (tag_id, file_id)
The two PK's autoincrement.
I enter metadata and filenames with a form, but the problem is the coding
required after I POST. Here's the relevant portion of the form:
<tr>
<td><TEXTAREA class="expands" name="item_desc" rows="8" cols="35"></TEXTAREA></td>
<td <input name=[b]"tags"[/b] type="text" size="35" />
<td <input name="item_pages" type="text" size="5" />
<td> <input name="item_name" type="text"></input></td>
</tr>
// Check to see if any tags were entered. If no tags were entered, exit
// and reset the form for the next file entry. If tags exist, explode tags
// into array.
if !($_POST('tags')) then [code to exit and reset form]
else $taglist=explode (" ", ($_POST('tags'));
// Check each $taglist array field to see if the tag already exists in 'Tags'
// If tag does not yet exist in 'Tags', insert into 'Tags' and retrieve
// its Tags.tag_id. If tag exists in 'Tags', get its Tags.tag_id, but make
// no insertion
for each [] in $tagarray {
select row "$tagarray[]" from 'Tags.tag';
if select=null { INSERT into Tags (tag) VALUE ('$tagarray[]');
$newtagid=mysql_insert_id();
}
else $newtagid=(SELECT 'Tags.tag_id' from selected row above);
// Insert the tag_id and file_id together in 'Tags2Files'
INSERT into Tags2Files (tag_id, file_id) VALUE ('$newtagid', '$newfileid');
}
<tr>
<td><TEXTAREA class="expands" name="file_desc" rows="8" cols="35"></TEXTAREA></td>
<td <input name=[b]"tags"[/b] type="text" size="35" />
<td <input name="file_pages" type="text" size="5" />
<td> <input name="file_name" type="text"></input></td>
</tr>
Sorry about the confusion.