inserting checkbox data into database
Posted: Mon Jul 13, 2009 6:45 pm
Ok so this is really frusterating me. I have checked tons of examples around the net and tried every way and NONE of them are working. I'm not new to PHP, and i really dont know why this is happening.
All i want to do is take an array of checkbox's and insert them into different columns in the database. Here is my HTML
and here is my php
currently there is nothing there to handle the checkbox array, so what would i have to put in the php to handle it?
thanks!
All i want to do is take an array of checkbox's and insert them into different columns in the database. Here is my HTML
Code: Select all
<label for="title">Title:</label>
<input type="text" name="title" id="title" value="<?php print $title;?>" />
<label for="thumbnail">Thumbnail:</label>
<input type="file" name="thumbnail" id="thumbnail" />
<label for="description">Description:</label>
<textarea name="description" id="description"> <?php print $description;?> </textarea>
<div class="responsible">
<label for="responsible" id="responsible">Responsible For:</label>
<input type="checkbox" name="resp" value="arch" id="arch" />
<label for="arch">Architecture</label>
<br />
<input type="checkbox" name="resp" value="bran" id="bran" />
<label for="bran">Branding</label>
<br />
<input type="checkbox" name="resp" value="desi" id="desi" />
<label for="desi">Design</label>
<br />
<input type="checkbox" name="resp" value="idev" id="idev" />
<label for="idev">Interface Development</label>
<br />
<input type="checkbox" name="resp" value="bkpg" id="bkpg" />
<label for="bkpg">Backend Programming</label>
<br />
<input type="checkbox" name="resp" value="ddev" id="ddev" />
<label for="ddev">Database Development</label>
</div>Code: Select all
if(isset($_POST['create'])):
extract($_POST);
mysql_query("INSERT INTO $table VALUES (
'',
'$title',
'$thumbnail',
'$description',
'$arch',
'$desi',
'$bkpg',
'$bran',
'$idev',
'$ddev'
)") or die(mysql_error());
endif;
thanks!