Basically I'm trying to upload details of articles onto my site, and each article has certain tags relating to its subject, which can be selected via checkbox. Simplified:
Code: Select all
<form name="update" method="post" action="updatetest.php">
<table border="0">
<tr><td>Article id: <input type="text" name="id"></td></tr>
<tr><td><input type="checkbox" name="tags[]" value="first.htm">Stuff
<br><input type="checkbox" name="tags[]" value="more.htm">Different Stuff
<br><input type="checkbox" name="tags[]" value="etc.htm">Another Subject
</td></tr>
<tr><td><input type="submit" value="submit"></td></tr>
</form>Code: Select all
<?
if (isset($_POST['submit'])) {
include '../db.php';
include '../common.php';
$id = $_POST['id'];
if (!empty($_POST['tag'])) {
for($i=0; $i<count($_POST['tag']); $i++) {
$tag = $_POST['tag'][$i];
$sql = "INSERT INTO tagstest SET id='$id', tag='$tag'";
$result = mysql_query($sql);
if ($result) {
error('Tag details added');
}
else {
error('Error connecting to database');
}
}
}
}
?>