HI,
I am having trouble getting the values from a dropdown <SELECT>list and using the selected value as a part of my SQL statement.
I am using the following in my PHP:
$field = $_POST['field_drop'];
// sending query for data
$result1 = mysql_query("SELECT '$field' FROM mail WHERE date BETWEEN '$start_date' AND '$end_date' ORDER BY date ASC");
if (!$result1) {
die("Query to show fields from table failed");
}
and the following form in my HTML:
<SELECT name="field_drop">
<OPTION VALUE="sentwebmails">Sent Webmails</OPTION>
<OPTION VALUE="sentfromsitedotcom">Sent from site.com</OPTION>
<OPTION VALUE="senttositemode">Sent to siteMode</OPTION>
<OPTION VALUE="receivedtositedotie">Received to site.ie</OPTION>
<OPTION VALUE="rejected">Rejceted</OPTION>
<OPTION VALUE="total">Total</OPTION>
</SELECT>
<input type="submit" value="Field">
If I just try print the output using <?php print $field ?> within my HTML it will print the selected option but the SQL querl will not bring back any data.
If anyone can help me I would be greatly appreciative.
Thanx in advance!!