Hi,
I have a form and need to try to work out how to get the values checked from them into the url as a series of values.
The url on entering the page will look like this -
result.php?Country=1®ions=&category=&star=
But for the page to read the values of the checkboxes, I need it to output to the url so it ends up like when for example 2 checkboxes are selected
result.php?regions%5B%5D=89®ions%5B%5D=221&Country=1
The form is set up like this at the moment without a submit button
<form name="form1" id="myForm"
<?php
$r=mysql_query("SELECT DISTINCT(tbl_resorts.Id_Rsrt), Nom_Rsrt, IdCntry_Rsrt, Id_show, Act_Hot, IdRsrt_Hot FROM tbl_resorts LEFT JOIN tbl_hotels ON (tbl_resorts.Id_Rsrt=tbl_hotels.IdRsrt_Hot) WHERE (tbl_resorts.IdCntry_Rsrt='".$selectCountry."') AND (tbl_hotels.Act_Hot='1') ORDER BY Nom_Rsrt");
while($q=mysql_fetch_assoc($r)){ ?>
<input type="checkbox" name="regions[]" value="<?php echo $q['Id_Rsrt']?>" <?php echo (isset($_REQUEST['regions']) && in_array($q['Id_Rsrt'], $_REQUEST['regions'])) ? 'checked="checked"' : '' ?> class="inline" /><?php echo $q['Nom_Rsrt']?></li>
<?php } ?>
</form>
So basically I need help to be able to submit the values of the selected checkboxes to the url on submit.
This is how I am reading those values to allow the page to display the results from the region selection within the country already selected to get to the page
if($_SERVER['REQUEST_METHOD']=='POST' ) { $post=$_POST; }
elseif($_SERVER['REQUEST_METHOD']=='GET' ) { $post=$_GET; }
if (!empty($_GET['regions']) ? $_GET['regions'] : null) {
$regionsArray = array();
foreach($_GET['regions'] as $regions) {
$regionsArray[] = '\''.$regions.'\'';
}
$selectRegion = filter_input(INPUT_GET, 'regions', FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY);
$selectRegion = $selectRegion ? $selectRegion : array();
$regionData = implode(',', $regionsArray);
$sqlregion = ' AND IdRsrt_Hot IN ('. $regionData .' )';
}