I have the following checkboxes on one page
[code]
Brass: <input class=”fieldStyle” type=”checkbox” name=”brass” style=”border: 0px”><br>
Early Music: <input class=”fieldStyle” type=”checkbox” name=”earlymusic” style=”border: 0px”><br>
Jazz: <input class=”fieldStyle” type=”checkbox” name=”jazz” style=”border: 0px”><br>
Keyboards: <input class=”fieldStyle” type=”checkbox” name=”keyboards” style=”border: 0px”><br>
Percussion: <input class=”fieldStyle” type=”checkbox” name=”percussion” style=”border: 0px”><br>
Rock and Pop: <input class=”fieldStyle” type=”checkbox” name=”rockandpop” style=”border: 0px”><br>
Strings: <input class=”fieldStyle” type=”checkbox” name=”strings” style=”border: 0px”><br>
Traditional: <input class=”fieldStyle” type=”checkbox” name=”traditional” style=”border: 0px”><br>
Vocal: <input class=”fieldStyle” type=”checkbox” name=”vocal” style=”border: 0px”><br>
Woodwind: <input class=”fieldStyle” type=”checkbox” name=”woodwind” style=”border: 0px”><br>
World: <input class=”fieldStyle” type=”checkbox” name=”world” style=”border: 0px”><br>
And I have a field in my database for each of these checkboxes
i.e the database contains the following fields
brass
earlymusic
jazz
etc
Basically the page adds the details of a new musician to the database. Each musician can have multiple categories of music.
My code to update the database is as follows:
[code]
include “config.php”;
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die (“Cannot connect to database”);
$name = $_POST[‘bandname’];
$brass = $_POST[‘brass’];
$earlymusic = $_POST[‘earlymusic’];
$jazz = $_POST[‘jazz’];
$keyboards = $_POST[‘keyboards’];
$percussion = $_POST[‘percussion’];
$rockandpop = $_POST[‘rockandpop’];
$strings = $_POST[‘strings’];
$traditional = $_POST[‘traditional’];
$vocal = $_POST[‘vocal’];
$woodwind = $_POST[‘woodwind’];
$world = $_POST[‘world’];
$website = $_POST[‘link’];
$description = $_POST[“description”];
$query = “INSERT INTO musicianstb(name, brass, earlymusic, jazz, keyboards, percussion, rockandpop, strings, traditional, vocal, woodwind, world, website, description)
VALUES(‘$name’,’$brass’,’$earlymusic’,’$jazz’,’$keyboards’,’$percussion’,’$rockandpop’,’$strings’,’$traditional’,’$vocal’,’$woodwind’,’$world’,’$website’,’$description’)”;
$result = mysql_query($query);
if (!$result) {
die(‘Invalid query: ‘ . mysql_error());
}
But unfortunately it is setting a value of zero for all the checkbox fields in the database even if they have been checked.
Any help getting this to work much appreciated.
Thanks
Paul