I have the checkboxes in the backend and file admin/ban-country-ip.php
CONTENT HERE IS GETTING THE COUNTRY list with checkbox in the admin backend
<?php
$countryiso = mysql_query("SELECT distinct country_name as country_name FROM location_country");
echo '<table>';
echo '<th>Country</th><th> Add/Remove </th>';
while ($row = mysql_fetch_assoc($countryiso)) {
echo '<tr>';
echo '<td>'. $row['country_name'] . '</td>';
echo '<td><input type="checkbox"></td>';
echo '</tr>';
}
echo '</table>';
?>
AND in the frond end registration it ECHO's them in registration.php.
$ctrstr="";
$res=mysql_query("select * from location_country where code NOT IN('A1','A2','AP','EU') order by name");
$ctrstr.="<select name=\"country\" id=\"country\" onChange=\"loadState();\" >
<option value=\"\" selected=\"selected\">-Select Country-</option>";
while($row=mysql_fetch_row($res))
{
if($country==$row[0])
$ctrstr.="<option value=\"$row[0]\" selected>$row[1]</option>";
else
$ctrstr.="<option value=\"$row[0]\">$row[1]</option>";
}
$ctrstr.="</select>";
I would like to know how can i hide a value from a select list using checkbox. When i un-check in the back-end a country, it should also be removed in the front end in the select field. If i check it again, should be showing again. I want to mention that the countries are stocked in mysql in a column.
MYSQL - TABLE STRUCTURE
# Name Type Collation Attributes Null Default Extra
1 code varchar(2) utf8_unicode_ci No
2 name varchar(255) utf8_unicode_ci No
select * from location_country where code NOT IN('A1','A2','AP','EU') AND your_new_column =1 order by name
thats all for the front end only you have to build the update/add functionality with your_new_column – dianuj Sep 21 at 15:51countries[]
array<input type="checkbox" name="countries[]">
get all the posted values from the form first update all the country'syour_new_column
to 0 then loop through the posted values and updateyour_new_column
to 1 hope you got my idea – dianuj Sep 21 at 16:04