Codice PHP:
$q "INSERT INTO linkstotags ('link_id','tag_id') VALUES (".$lastlink.",".$_POST['tag".$n."'].")"