Hi,
Using the following selection criteria, I am able to list the data from mysql db, but I would like to provide the following options for users: Select All Data, Select None. I am not sure if this is possiible. Any help would be greatly appreciated.
Here's my code
//OUTPUT
***
Using the following selection criteria, I am able to list the data from mysql db, but I would like to provide the following options for users: Select All Data, Select None. I am not sure if this is possiible. Any help would be greatly appreciated.
Here's my code
Code:
<h4>SEARCH</h4>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method = "post" target = "right">
//1st DROPDOWN
Date<br>
<select size="1" name="search">
<?php
$con = mysql_connect("localhost","****","****");
if (!$con) {die('Database is down: ' . mysql_error());}
mysql_select_db("test",$con);
$query = ("select distinct date from **** order by date desc");
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo "<option value=\"$row[date]\">$row[date]</option>";
}
?>
</select>
//2nd DROPDOWN
<br><br>
Product<br>
<select size="1" name="search1">
<?php
$con = mysql_connect("localhost","****","****");
if (!$con) {die('Database is down: ' . mysql_error());}
mysql_select_db("test",$con);
$query = ("select distinct productname from *** order by productname desc");
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
//echo "<option value=\"$row[date]\">.$row[date].'</option>'";
echo "<option value=\"$row[productname]\">$row[productname]</option>";
}
?>
</select>
<input type="Submit" value="Submit" name="Submit">
</form>
//ASSINGING THE SELECTED FIELDS TO A VARIABLE
$search = empty($_POST['search'])? die ("ERROR: Enter Search Criteria") : mysql_escape_string($_POST['search']);
$search1 = empty($_POST['search1'])? die ("ERROR: Enter Search Criteria") : mysql_escape_string($_POST['search1']);
//QUERY
$query = "SELECT * FROM *** where date = '$search' and productname = '$search1' or die (mysql_error());
$result = mysql_query($query) or die (mysql_error());
$num = mysql_numrows($result);
mysql_close($connect);
//OUTPUT
***
Comment