if (isset($_POST['submit']))
I want validation to see one of checkbox is chekced
and if checkbox is checked... then user should select a option from dropdown..
<table width="282">
<tr> <td width="39%"> <input type="checkbox" name="hearaboutus[]" VALUE="Radio" <? if ($hearaboutus && in_array ("Radio", $hearaboutus)) echo ' checked="checked"'; ?>/>Radio </td>
<td width="58%" >
<?php
$query = "SELECT source_detail FROM hearaboutus WHERE source = 'Radio'";
$result = mysql_query($query, $db) or die(mysql_error());
echo '<select name="Drophearaboutus1" style="width:150px;">';
echo '<option value="" selected>'?> Select Station <? '</option> <br>';
while($row = mysql_fetch_assoc($result)){
$selected = $Drophearaboutus1 == $row['source_detail'] ? 'selected="selected"' : '';
echo '<option value="'.$row['source_detail'] .'" '.$selected.' >'.$row['source_detail'] . '</option><br>';
}
echo '</select>';
?>
</td></tr>
<tr><td> <input type="checkbox" name="hearaboutus[]" VALUE="Television" <? if ($hearaboutus && in_array ("Television", $hearaboutus)) echo ' checked="checked"'; ?>/>Television</td>
<td>
<?php
$query = "SELECT source_detail FROM hearaboutus WHERE source = 'Television'";
$result = mysql_query($query, $db) or die(mysql_error());
echo '<select name="Drophearaboutus2" style="width:150px;">';
echo '<option value="" selected>' ?> Select Channel <? '</option> <br>';
while($row = mysql_fetch_assoc($result)){
$selected = $Drophearaboutus2 == $row['source_detail'] ? 'selected="selected"' : '';
echo '<option value="'.$row['source_detail'] .'" '.$selected.'>'.$row['source_detail'] . '</option><br>';
}
echo '</select>';
?>
</td></tr>
<tr><td> <input type="checkbox" name="hearaboutus[]" VALUE="Print" <? if ($hearaboutus && in_array ("Print", $hearaboutus)) echo ' checked="checked"'; ?>/>Print</td>
<td>
<?php
$query = "SELECT source_detail FROM hearaboutus WHERE source = 'Print'";
$result = mysql_query($query, $db) or die(mysql_error());
echo '<select name="Drophearaboutus3" style="width:150px;">';
echo '<option value="" selected>' ?> Select Advertisement <? '</option> <br>';
while($row = mysql_fetch_assoc($result)){
$selected = $Drophearaboutus3 == $row['source_detail'] ? 'selected="selected"' : '';
echo '<option>'.$row['source_detail'] . '</option><br>';
}
echo '</select>';
?>
</td></tr>
</table>