This form obviously creates three checkboxes, but what I need is to store whatever is checked in the database and display it on the page. I've read many tutorials about checkboxes, but i've not been able to make anything work with my current code.
The checkbox code
Code: Select all
<tr>
<td height="39" class="key">
<label for="name">
<strong><?php echo JText::_('CHECK BOX 1'); ?></strong>:
</label>
</td>
<td>Please check box 1</td>
<td>
<input type="checkbox" <? echo $strIsChecked ?> name="checkbox_1"></td>
</tr>
<tr>
<td height="103" class="key"><strong><?php echo JText::_('CHECK BOX 2'); ?></strong></td>
<td>Please check box 2</td>
<td><input type="checkbox" name="checkbox_2" id="checkbox_2" /></td>
</tr>
<tr>
<td class="key"><strong><?php echo JText::_('CHECKBOX 3'); ?></strong></td>
<td>Please check box 3</td>
<td><input type="checkbox" name="checkbox_3" id="checkbox_3" /></td>
</tr>
<tr>Code: Select all
<form action="index.php" method="post" name="regJobSeeker" enctype="multipart/form-data">
<div class="col width-60">
<fieldset class="tpj_fieldset">
<legend><?php echo JText::_('USER INFORMATION'); ?></legend>
<table class="admintable">
<tr>
<td class="key">
<label for="name">
<?php echo JText::_('USER NAME'); ?> :
</label>
</td>
<td>
<strong><?php echo $user->name; ?></strong> - <?php
if(!empty($row->id))
{
$link = JRoute::_('index.php?option=com_user&view=user&task=edit');
?>
<a href="<?php echo $link; ?>"><?php echo JText::_('CHANGE PASSWORD OR EMAIL'); ?></a>
<?php
}
?>
</td>
</tr>
</table>
</fieldset>
</div>
<div class="col width-60">
<fieldset class="tpj_fieldset">
<legend><?php echo JText::_('EXPERIENCE / EDUCATION'); ?></legend>
<table class="admintable">
<tr>
<td class="key">
<label for="name">
<strong><?php echo JText::_('CURRENT POSITION'); ?></strong>:
</label>
</td>
<td>
<input class="inputbox" type="text" name="current_position" id="current_position" size="60" maxlength="100" value="<?php echo $row->current_position; ?>" />
</td>
</tr>
<tr>
<td class="key">
<label for="name">
<strong><?php echo JText::_('MAJOR'); ?></strong>:
</label>
</td>
<td>
<?php
$list_major = getSelectMajor('id_major',$row->id_major,'');
echo $list_major;
?>
</td>
</tr>
<tr>
<td class="key">
<label for="name">
<strong><?php echo JText::_('DEGREE LEVEL'); ?></strong>:
</label>
</td>
<td>
<?php
$list_degree_level = getSelectDegreeLevel('id_degree_level',$row->id_degree_level,'');
echo $list_degree_level;
?>
</td>
</tr>
</table>
</fieldset>
</div>
<div class="col width-60">
<fieldset class="tpj_fieldset">
<legend><?php echo JText::_('DESIRED EMPLOYMENT'); ?></legend>
<table class="admintable">
<tr>
<td width=150 height="28" class="key">
<label for="name">
<strong><?php echo JText::_('PRIMARY INDUSTRY'); ?></strong>:
</label>
</td>
<td>
<?php
$list_primary_industry = getSelectIndustry('id_industry1',$row->id_industry1,''); echo $list_primary_industry;
?>
</td>
<td> </td>
</tr>
<tr>
<td height="29" class="key">
<label for="name">
<strong><?php echo JText::_('SECONDARY INDUSTRY'); ?></strong>:
</label>
</td>
<td>
<?php
$list_secondary_industry = getSelectIndustry('id_industry2',$row->id_industry2,''); echo $list_secondary_industry;
?>
</td>
<td> </td>
</tr>
<tr>
<td height="31" class="key">
<label for="name">
<strong><?php echo JText::_('POSITION TYPE'); ?></strong>:
</label>
</td>
<td>
<?php
$list_position_type = getSelectPositionType('id_pos_type',$row->id_pos_type,''); echo $list_position_type;
?>
</td>
<td> </td>
</tr>
<tr>
<td height="33" class="key">
<label for="name">
<strong><?php echo JText::_('MINIMUM SALARY'); ?></strong>:
</label>
</td>
<td nowrap="nowrap">
<input class="inputbox" type="text" name="min_salary" id="min_salary" size="40" maxlength="100" value="<?php echo $row->min_salary; ?>" />
<?php
$list_salary_type = getSelectTypeSalary('id_type_salary',$row->id_type_salary,''); echo $list_salary_type;
?>
</td>
<td nowrap="nowrap"> </td>
</tr>
<tr>
<td height="33" class="key">
<label for="name">
<strong><?php echo JText::_('IN CURRENCY'); ?></strong>:
</label>
</td>
<td nowrap="nowrap">
<input class="inputbox" type="text" name="currency_salary" id="currency_salary" size="10" maxlength="100" value="<?php echo $row->currency_salary; ?>" />
</td>
<td nowrap="nowrap"> </td>
</tr>
<tr>
<td height="37"td class="key">
<label for="name">
<strong><?php echo JText::_('UPLOAD FOTO'); ?></strong>:
</label>
</td>
<td nowrap="nowrap">
<?php
$db =& JFactory::getDBO();
$switch = whichUse($user->id);
switch($switch)
{
case 1:
$query = "SELECT avatar FROM #__comprofiler WHERE avatarapproved='1' AND user_id='$row->user_id'";
$db->setQuery($query);
$i = $db->loadResult();
if($i)
{
$img = JPATH_SITE.DS.'images'.DS.'comprofiler'.DS.$i;
$pimg = JURI::base().'images/comprofiler/'.$i.'?'.time();
}
else
{
$img = JPATH_SITE.DS.'images'.DS.'tpjobs'.DS.$row->user_id.'.jpg';
$pimg = JURI::base().'images/tpjobs/'.$row->user_id.'.jpg?'.time();
}
break;
case 2:
$query = "SELECT avatar FROM #__community_users WHERE userid='$row->user_id'";
$db->setQuery($query);
$i = $db->loadResult();
if($i)
{
$img = JPATH_SITE.DS.$i;
$pimg = JURI::base().$i.'?'.time();
}
else
{
$img = JPATH_SITE.DS.'images'.DS.'tpjobs'.DS.$row->user_id.'.jpg';
$pimg = JURI::base().'images/tpjobs/'.$row->user_id.'.jpg?'.time();
}
break;
default:
$img = JPATH_SITE.DS.'images'.DS.'tpjobs'.DS.$row->user_id.'.jpg';
$pimg = JURI::base().'images/tpjobs/'.$row->user_id.'.jpg?'.time();
break;
}
if(file_exists($img)) {
echo '<img src="'.$pimg.'">';
}
else if ($row->id)
{
$img = JURI::base().'components/com_tpjobs/images/nophoto.gif';
echo '<img src="'.$img.'">';
}
?>
<input type="file" name="photo" class="inputbox" />
</td>
<td nowrap="nowrap"> </td>
</tr>
<tr>
<td class="key"> </td>
<td nowrap="nowrap"> </td>
<td nowrap="nowrap"> </td>
</tr>
<tr>
<td height="39" class="key">
<label for="name">
<strong><?php echo JText::_('CHECK BOX 1'); ?></strong>:
</label>
</td>
<td>Please check box 1</td>
<td>
<input type="checkbox" <? echo $strIsChecked ?> name="checkbox_1"></td>
</tr>
<tr>
<td height="103" class="key"><strong><?php echo JText::_('CHECK BOX 2'); ?></strong></td>
<td>Please check box 2</td>
<td><input type="checkbox" name="checkbox_2" id="checkbox_2" /></td>
</tr>
<tr>
<td class="key"><strong><?php echo JText::_('CHECKBOX 3'); ?></strong></td>
<td>Please check box 3</td>
<td><input type="checkbox" name="checkbox_3" id="checkbox_3" /></td>
</tr>
<tr>
<td class="key">
<label for="name">
</label>
<td> </td>
<td> </td>
</tr>
</table>
</fieldset>
</div>
<?php HTML_front_tpjobs::showCustom($custom, $row->user_id); ?>
<?php if($row->id > 0){?>
<input type="button" value="<?php echo JText::_('EDIT PROFILE BTN'); ?>" onclick="javascript:validateregJobSeeker();" class="button"/>
<?php }else{ ?>
<?php
$config = & JComponentHelper::getParams('com_tpjobs');
$cv_review=$_POST[cv_review]; $sql="INSERT INTO #_tpjobs_jobseeker (cv_review) VALUES('$cv_review')";
$termid = $config->get('termarticleid');
$link = JRoute::_("index.php?option=com_content&view=article&id=".$termid);
?>
<p>By clicking on 'I accept' below you are agreeing to our <a href="<?php echo $link; ?>" target="_blank">Terms and Conditions</a></p>
<input type="button" value="<?php echo JText::_('SET AS JOBSEEKER'); ?>" onclick="javascript:validateregJobSeeker();" class="button"/>
<?php } ?>
<input type="hidden" name="option" value="<?php echo $option; ?>" />
<input type="hidden" name="task" value="savejobseeker" />
<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHTML::_('form.token'); ?>
</form>Could someone explain to me - in simple terms - how checkboxes in php work with a sql database, i'm completely lost.
Thanks in advance