I have a form that asks customers which of 42 categories they are
interested in. I have created three tables to handle the results.
Everything writes to the pf_survey table with no problems and only the
first checkbox selected writes to the cat_survey table. What am I
missing? Is it something in my code or do I need to do something special
to my cat_survey table? Thanks.
pf_survey
Survey_id,Ques,date etc
cat_survey
Survey_id, category_id
Categories
Category_id, category_name
Here is the code
<?php
$protected=1;
include "header.php";
$perm->check('admin');
$username = $auth->auth["uname"];
$_POST['category_id'];
if ($Submit) {
$res=mysql_query("insert into pf_survey
(customer_number,interest_pf,return_call,call_date,comments,submit_time,
username)
values
('$customer_number','$interest_pf','$return_call','$call_date','$comment
s',now(),'$username')",$dbi);
if (!$res) {
print "<p>Couldn't insert your record:
".mysql_error()."</p>\n";
}
$pfsurvey_id=mysql_insert_id($dbi);
$this->pfsurvey_id=$pfsurvey_id;
$numcat = count($category);
if ($numcat>1){
$category_id=implode(",",$category);
} elseif ($numcat==1){
$category_id=$category;
}
$cat=mysql_query("insert into cat_survey
(pfsurvey_id,
category_id) values
('$pfsurvey_id','$category_id')",$dbi);
if (!$cat) {
print "<p>Couldn't insert your record:
".mysql_error()."</p>\n";
}
print "<p>Loaded your data
correctly.</p>\n";
print "<p><a href=pf_survey.php>Add
another record.</a></p>\n";
} else {
?>
<form action="<?php print $sess->self_url(); ?>" method="post">
<?php $sess->hidden_session(); ?>
<div align="left">
<p>Customer Number
<input type="text" name="customer_number" size="6" maxlength="6">
(look on catalog for label with number)<br>
<br>
1. Are you interested in Power Forward? Yes
<input type="checkbox" name="interest_pf" value="Y">
No
<input type="checkbox" name="interest_pf" value="N">
<br>
2. Would you like for us to call back? Yes
<input type="checkbox" name="return_call" value="Y">
No
<input type="checkbox" name="return_call" value="N">
Date to call back (yr-mm-dd)
<input type="date" name="call_date" maxlength="10" size="12">
</p>
<p>In which of the following categories are you interested?<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td > Air Compressors
<input type="checkbox" name="category[]" value="1">
<br>
Air Tools
<input type="checkbox" name="category[]" value="2">
<br>
Animal Traps
<input type="checkbox" name="category[]" value="3">
<br>
Apparel-Work Clothing
<input type="checkbox" name="category[]" value="39">
<br>
Bending Brakes
<input type="checkbox" name="category[]" value="4">
<br>
Blades
<input type="checkbox" name="category[]" value="42">
<br>
Brick Tools
<input type="checkbox" name="category[]" value="38">
<br>
Business Supplies
<input type="checkbox" name="category[]" value="26">
<br>
Carpet & Drying
<input type="checkbox" name="category[]" value="5">
<br>
Concrete
<input type="checkbox" name="category[]" value="6">
<br>
Detail Shop
<input type="checkbox" name="category[]" value="41">
<br>
Drain Cleaners
<input type="checkbox" name="category[]" value="7">
<br>
Drilling & Boring
<input type="checkbox" name="category[]" value="8">
<br>
Dry Wall Tools
<input type="checkbox" name="category[]" value="9">
</td>
<td>Engines & Motors
<input type="checkbox" name="category[]" value="10">
<br>
Floor Maintenance Tools
<input type="checkbox" name="category[]" value="11">
<br>
Generators
<input type="checkbox" name="category[]" value="12">
<br>
Heaters
<input type="checkbox" name="category[]" value="13">
<br>
Lawn & Garden
<input type="checkbox" name="category[]" value="15">
<br>
Lighting
<input type="checkbox" name="category[]" value="40">
<br>
Magnetic Tools
<input type="checkbox" name="category[]" value="16">
<br>
Marine Propellers
<input type="checkbox" name="category[]" value="37">
<br>
Material Handling
<input type="checkbox" name="category[]" value="17">
<br>
Nailers & Supplies
<input type="checkbox" name="category[]" value="18">
<br>
Painters & Supplies
<input type="checkbox" name="category[]" value="19">
<br>
Party
<input type="checkbox" name="category[]" value="21">
<br>
Pipe Threaders
<input type="checkbox" name="category[]" value="22">
<br>
Power Tools & Blades
<input type="checkbox" name="category[]" value="23">
</td>
<td valign="top" >Pressure Washers
<input type="checkbox" name="category[]" value="24">
<br>
Pumps & Hoses
<input type="checkbox" name="category[]" value="25">
<br>
Roofing
<input type="checkbox" name="category[]" value="27">
<br>
Safety
<input type="checkbox" name="category[]" value="28">
<br>
Scaffolding & Accessories
<input type="checkbox" name="category[]" value="29">
<br>
Shop Tools
<input type="checkbox" name="category[]" value="30">
<br>
Surface Preparation
<input type="checkbox" name="category[]" value="32">
<br>
Surveying
<input type="checkbox" name="category[]" value="33">
<br>
Steel & Carbide
<input type="checkbox" name="category[]" value="31">
<br>
Trailer & Towing
<input type="checkbox" name="category[]" value="34">
<br>
Ventilation
<input type="checkbox" name="category[]" value="35">
<br>
Welding
<input type="checkbox" name="category[]" value="36">
</td>
</tr>
</table>
<br>
Additional Comments: <br>
<textarea name="comments" cols="60" rows="4"></textarea>
<br>
</div>
<p align="left">
<input type="submit" name="Submit" value="Submit">
<br>
</p>
<div align="left"> Thank you for your time!<br>
Visit our website at www.mtadistributors.com </div>
</form>
<?php } ?> <?php include "footer.php"; ?>
Duffy Betterton
Director of Publications
615-277-3265
[EMAIL PROTECTED]
www.mtadistributors.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php