php - inserting multiple checkboxes into one column but in multiple rows -
i have page multiple checkboxes. code inserts each checkbox separate column, although causing issues when looking pull information out again.
i had been able insert 1 column answers went 1 field rather separate rows. need user_id of user logged in insert each row each box checked well.
can please copy , amend code able insert 1 column (response) , separate rows, along user_id.
here code, thank you
<?php session_start(); include_once 'dbconnect.php'; if(!isset($_session['user'])) { header("location: index.php"); } $res=mysql_query("select * users user_id=".$_session['user']); $userrow=mysql_fetch_array($res); if(isset($_post['submit'])) { header("location: enisatvids.php"); @$userid=$_session['user']; @$checkbox1=$_post['log']; @$checkbox2=$_post['worktray']; @$checkbox3=$_post['visual']; @$checkbox4=$_post['changepd']; @$checkbox5=$_post['logout']; @$checkbox6=$_post['clientsearch']; @$checkbox7=$_post['startassessment']; @$checkbox8=$_post['finalise']; @$checkbox9=$_post['print']; @$checkbox10=$_post['hcn']; @$checkbox11=$_post['lcid']; @$checkbox12=$_post['soscare']; @$checkbox13=$_post['reassign']; @$checkbox14=$_post['close']; $query="insert enisatanswer (user_id,log,worktray,visual,changepd,logout,clientsearch,startassessment,finalise,print,hcn,lcid,soscare,reassign,close) values ('$userid', '$checkbox1', '$checkbox2','$checkbox3', '$checkbox4', '$checkbox5', '$checkbox6','$checkbox7', '$checkbox8','$checkbox9', '$checkbox10','$checkbox11', '$checkbox12', '$checkbox13', '$checkbox14')"; mysql_query($query) or die (mysql_error() ); if($query==true) { echo'<script>alert("your choices have inserted \n \n please click on display enisat tutorials @ buttom of page view videos ")</script>'; } else { echo'<script>alert("failed insert")</script>'; } } ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>welcome - <?php echo $userrow['username']; ?></title> /<link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="header"> <div id="left"> <label>nhsct enisat tutorials</label> </div> <div id="right"> <div id="content"> welcome <?php echo $userrow['forename']; ?> <a href="logout.php?logout">sign out</a> </div> </div> </div> <br> <p align="center"><img src="title.jpeg" width="400"height="100" alt="title.jpeg"> <br> <br> <center> <h2>please select tasks require assistance with, before clicking display enisat tutorials:<h2> <br> <table align="center" height="0" width="70%" border="1" bgcolor = "white"> <form action="" method="post" <tr> <td colspan="2">tick each relevant box:</td> </tr> <tr> <td>how login</td> <td><input type="checkbox" name="log" value="1"></td> <tr> <td>how manage worktray</td> <td><input type="checkbox" name="worktray" value="1"></td> <tr> <td>how change visual settings (colours , text size)</td> <td><input type="checkbox" name="visual" value="1"></td> </tr> <tr> <td>how change own password on system</td> <td><input type="checkbox" name="changepd" value="1"></td> </tr> <tr> <td>how logout of system</td> <td><input type="checkbox" name="logout" value="1"></td> </tr> <tr> <td>how search client on system</td> <td><input type="checkbox" name="clientsearch" value="1"></td> </tr> <tr> <td>how start assessment</td> <td><input type="checkbox" name="startassessment" value="1"></td> </tr> <tr> <td>how finalise assessment</td> <td><input type="checkbox" name="finalise" value="1"></td> <tr> <td>how print assessment</td> <td><input type="checkbox" name="print" value="1"></td> </tr> <tr> <td>how create client , referral manually through find on h+c</td> <td><input type="checkbox" name="hcn" value="1"></td> </tr> <tr> <td>how submit referral lcid (lcid users only)</td> <td><input type="checkbox" name="lcid" value="1"></td> </tr> <tr> <td>how submit referral soscare (soscare users only)</td> <td><input type="checkbox" name="soscare" value="1"></td> </tr> <tr> <td>how reassign referral on enisat</td> <td><input type="checkbox" name="reassign" value="1"></td> </tr> <tr> <td>how close referral on enisat</td> <td><input type="checkbox" name="close" value="1"></td> </tr> <tr> <td <td><button name="submit" type="submit" onclick="window.location.href='enisatvids.php'">display enisat tutorials</button></td> </tr> </table> </div> </form> </body> </html>
Comments
Post a Comment