i make a php page in which i post data i want when post data is equal to option value then option value show selected,here is my post data:
Array (
[events] => Array
[fromdate] => February 12, 2014 3:10 PM
[todate] => February 19, 2014 3:10 PM
[description] => hfhhhhhhhhhhhhhhhhhh
[subject] => fhhhhhhhhhhhhhhhhhh
[fromname] => gjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
[replyto] => gjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
[senddatetime] => February 12, 2014 3:10 PM
[timezone] => America/Los_Angeles
[message] =>
dhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
[submit_skip] => Continue
)
and here is my code:
$select = sprintf ("SELECT event_id,event_name
FROM `events`
WHERE (`user_id` = '%s') order by event_name",
$GLOBALS ['mysqli']->real_escape_string ($_SESSION['user_id']));
$res = $GLOBALS ['mysqli']->query ($select) or die ($GLOBALS ['mysqli']->error . __LINE__);
if ($res->num_rows > 0)
{
while($row = $res->fetch_assoc ())
{
foreach( $_POST['events'] as $val ){ ?>
<option value="<?= $row['event_id'];
if($row['event_id'] == $val) echo "selected";
?>">
<?=$row['event_name']?>
</option>
<?
}
}
}
?>
</select>
i want [events] => Array checked in select option and if events value matched select box show selected,how i do this?
when i run this error show:
Warning: Invalid argument supplied for foreach() in C:\wamp\www\ticket_inspector_new\forms_hd87wblfo084wgdtry\form_email_compose