I've got a couple of issues here with setting up checkboxes and radio buttons.
First of all - when i submit it, the checkboxes never return the values that I've inputted in them (in this case, checked) - they still return the same list with check boxes, but this time, unchecked. Whereas the ones I want checked before submitting are not shown checked the second time...what do I do?
This is what the form looks like: ![This is what the form looks like:][1]
I want it to show ticked check boxes after I submit them.
Here's the releant HTML:
<br /><br />
<H2 align="center">SKILLS SET</H2>
<br />
<label for="skills" size="3">Pick Your Skill(s): </label>
<br /><br />
<tr>
<table border='1' cellspacing='0'>
<colgroup>
<col span='1'>
</colgroup>
<tr>
<td>Engineering Services</td>
<td>Information Technologies</td>
</tr> <!-- This one was missing -->
<tr>
<td valign="top">
<?php
$list = "SELECT * FROM skillsset WHERE category='Engineering' ORDER BY skills ASC";
//$list = "SELECT * FROM specifications ";
//$list1 = "SELECT * FROM specifications ORDER BY category ASC Limit 2";
$listAHI = $dbs ->prepare($list);
$listAHI -> execute();
//while($row1 = $listAHI1 ->fetch(PDO::FETCH_ASSOC)){
while($row = $listAHI ->fetch(PDO::FETCH_ASSOC))
{
$skills = $row["skills"];
$category = $row["category"];
echo "<input type='checkbox' name='skills[]' value='$skills'> $skills<br /> ";
//$category = $row["category"];
//$specifications = $row["specifications"];
//echo "$category <input type='checkbox' name='$specifications' value='$specifications'> $specifications </td>";
}
//while($row1 = $listAHI1 ->fetch(PDO::FETCH_ASSOC)){
//$category = $row1["category"];
//echo "<input type='checkbox' name='$specifications' value='$specifications'> $specifications ";
//echo "$category";
?>
</td>
<td valign="top">
<?php
$list = "SELECT * FROM skillsset WHERE category='Information' ORDER BY skills ASC";
//$list = "SELECT * FROM specifications ";
//$list1 = "SELECT * FROM specifications ORDER BY category ASC Limit 2";
$listAHI = $dbs ->prepare($list);
$listAHI -> execute();
//while($row1 = $listAHI1 ->fetch(PDO::FETCH_ASSOC)){
while($row = $listAHI ->fetch(PDO::FETCH_ASSOC))
{
$skills = $row["skills"];
$category = $row["category"];
echo "<input type='checkbox' name='skills[]' value='$skills'> $skills<br />";
//$category = $row["category"];
//$specifications = $row["specifications"];
//echo "$category <input type='checkbox' name='$specifications' value='$specifications'> $specifications </td>";
}
//while($row1 = $listAHI1 ->fetch(PDO::FETCH_ASSOC)){
//$category = $row1["category"];
//echo "<input type='checkbox' name='$specifications' value='$specifications'> $specifications ";
//echo "$category";
?>
</td>
</tr>
</table>
I want it to look something like this after I click the submit button:
![Desired outcome][2]
How do I make this work properly?
For text input - I used the following code: value="<?php if(isset($_POST['first_name'])) { echo $_POST['first_name']; } ?>"
However, for checkboxes, if I use that code, it gives me an error because
- it's a check box and
- it's being printed from a string which retrieves the list from a database in php my admin.
So how am I able to make it return the previously checked boxes after I click submit or save the data?
http://ift.tt/1CMuU2v http://ift.tt/1DiHGDT
here's my insert query - don't got an update query yet -
along with the arrays variable being imploded...
if (isset($_POST["submitd"]) && $_POST["submitd"] == "Save" ){ $specifications = implode(",",$_POST['specifications']); $skills = implode(",",$_POST['skills']);
$query567="INSERT into emprecords(id, first_name, middle_names, last_name, street, unit, city, region, postalcode, country, email, businessnumber, phonecountry, phonearea, phone, cellphonecountry, cellphonearea, cellphone, specifications, type, position, startingdate, desiredsalary, additionalinfo, skills, name, institution, instaddress, monthto, toyear, monthto1, toyear1, graduate, averages,company,position1, tasks, monthto2, toyear2, monthto3, toyear3, location,supervisor, startingsalary, endsalary, reasons, maywe, first_name1, middle_names1, last_name1, company1, relationship, email1, phone1, cellphone1, street1, unit1, city1, region1, postalcode1, country1) VALUES('$id', '$first_name', '$middle_names', '$last_name', '$street', '$unit', '$city', '$region', '$postalcode', '$country', '$email','$businessnumber', '$phonecountry', '$phonearea', '$phone', '$cellphonecountry', '$cellphonearea','$cellphone','$specifications','$type','$position','$startingdate','$desiredsalary','$additionalinfo','$skills', '$name', '$institution', '$instaddress', '$monthto', '$toyear', '$monthto1', '$toyear1', '$graduate', '$averages', '$company', '$position1', '$tasks', '$monthto2','$toyear2','$monthto3','$toyear3','$location','$supervisor','$startingsalary','$endsalary','$reasons','$maywe','$first_name1','$middle_names1','$last_name1','$company1','$relationship','$email1','$phone1','$cellphone1','$street1','$unit1','$city1','$region1','$postalcode1','$country1');";
$vttvk = $dbs -> prepare($query567);
$vttvk -> execute(array(':id'=>$id,':first_name'=>$first_name,':middle_names'=>$middle_names,':last_name'=>$last_name,':street'=>$street,':unit'=>$unit,':city'=>$city,':region'=>$region,':postalcode'=>$postalcode,':country'=>$country,':email'=>$email, ':businessnumber'=>$businessnumber,':phonecountry'=>$phonecountry, ':phonearea'=>$phonearea, ':phone'=>$phone, ':cellphonecountry'=>$cellphonecountry, ':cellphonearea'=>$cellphonearea, ':cellphone'=>$cellphone, ':specifications'=>$specifications, ':type'=>$type, ':position'=>$position, ':startingdate'=>$startingdate, ':desiredsalary'=>$desiredsalary, ':additionalinfo'=>$additionalinfo, ':skills'=>$skills, ':name'=>$name, ':institution'=>$institution,':instaddress'=>$instaddress,':monthto'=>$monthto,':toyear'=>$toyear,':monthto1'=>$monthto1,':toyear1'=>$toyear1,':graduate'=>$graduate,':averages'=>$averages,':company'=>$company,':position1'=>$position1,':tasks'=>$tasks,':monthto2'=>$monthto2,':toyear2'=>$toyear2,':monthto3'=>$monthto3,':toyear3'=>$toyear3,':location'=>$location, ':supervisor'=>$supervisor,':startingsalary'=>$startingsalary,':endsalary'=>$endsalary, ':reasons'=>$reasons, ':maywe'=>$maywe, ':first_name1'=>$first_name1, ':middle_names1'=>$middle_names1, ':last_name1'=>$last_name1, ':company1'=>$company1, ':relationship'=>$relationship, ':email1'=>$email1, ':phone1'=>$phone1, ':cellphone1'=>$cellphone1, ':street1'=>$street1, ':unit1'=>$unit1, ':city1'=>$city1, ':region1'=>$region1, ':postalcode1'=>$postalcode1, ':country1'=>$country1));