I'm a beginner and I try to make an agriculture application, to gain some experience, and to try something advanced. But I can't figure out how to make searches within my application. I have:
- 4 select html elements
- 5 search boxes
For space reasons, I'll write just 3/14 columns for the html elements.
HTML code:
<form>
<!-- makes the global filter based on all the data from db -->
<select id="select1" name="select1" onchange="this.form.submit()">
<option value="">Select</option>
<option value="code">Code</option>
<option value="land">Land</option>
<option value="name">Name</option>
</select><br/>
<!-- makes a filter for a html column, based on a db column -->
<select id="select2" name="select2" onchange="this.form.submit()">
<option value="">All parcels</option>
<option value="P1">P1</option>
<option value="P2">P2</option>
<option value="P3">P3</option>
</select>
<!-- search boxes to filter 5 html columns -->
<input type="search" id="search1" name="search2">
<input type="search" id="search2" name="search2">
<input type="search" id="search3" name="search3">
<input type="search" id="search4" name="search4">
<!-- same as the previous select menu, just this is for another html column -->
<select id="select3" name="select3" onchange="this.form.submit()">
<option value="">Select</option>
<option value="MO">MO</option>
<option value="MA">MA</option>
<option value="ME">ME</option>
</select>
<!-- the 5th search box -->
<input type="search" id="search5" name="search5">
<!-- renders the data from db according to the selections made by the user or search terms -->
<table id="table" class="display" cellspacing="0" width="100%">
<tr>
<th id="code">Code</th>
<th id="land">Land</th>
<th id="name">Name</th>
</tr>
<tr>
<?php
require 'config.php'; # login to database
# ---- QUERY ----
?>
</tr>
</table>
<!-- this displays in the page as many rows as the user selects -->
<select name="select4" id="select4" onchange="this.form.submit()">
<option value="">Select</option>
<option value="1">1</option>
<option value="5">5</option>
<option value="10">10</option>
</select>
</form>
PHP code: I just put this block of code instead of "# ---- QUERY ----" from above, to populate the html columns within the page:
if(isset($_POST['select1'])){
$select1 = $_POST['select1'];
switch($select1){
case 'code':
$stmt = $db->query("SELECT * FROM users WHERE `code`='code'");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
<td id="td"><?php echo $row['land'];?></td>
<td id="td2"><?php echo $row['name'];?></td>
</tr> <?php
}
break; # some more cases follows
} # end switch($select1)
} # end if(isset($_POST['select1']))
elseif(isset($_POST['select2'])){
$select2 = $_POST['select2'];
switch($select2){
case P1:
$stmt = $db->query("SELECT * FROM users WHERE `parcel` LIKE '%P1%'");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
<td id="td"><?php echo $row['land'];?></td>
<td id="td2"><?php echo $row['name'];?></td>
</tr> <?php
}
break; # some more cases here
} # end switch($select2)
} # end if(isset$_POST['select2'])
elseif(isset($_POST['search1'])){
$search1 = $_POST['search1'];
$stmt = $db->query("SELECT * FROM users WHERE `name` LIKE '%search1%'");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
<td id="td"><?php echo $row['land'];?></td>
<td id="td2"><?php echo $row['name'];?></td>
</tr> <?php
}
} # end elseif(isset($_POST['search1']))
elseif(isset($_POST['search2'])){
$search2 = $_POST['search2'];
$stmt = $db->query("SELECT * FROM users WHERE `cont_ref_a` LIKE '%search2%'");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
<td id="td"><?php echo $row['land'];?></td>
<td id="td2"><?php echo $row['name'];?></td>
</tr> <?php
}
} # end elseif(isset($_POST['search2']))
elseif(isset($_POST['search3'])){
$search3 = $_POST['search3'];
$stmt = $db->query("SELECT * FROM users WHERE `owner` LIKE '%search3%'");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
<td id="td"><?php echo $row['land'];?></td>
<td id="td2"><?php echo $row['name'];?></td>
</tr> <?php
}
} # end elseif(isset($_POST['search3']))
elseif(isset($_POST['search4'])){
$search4 = $_POST['search4'];
$stmt = $db->query("SELECT * FROM users WHERE `block` LIKE '%search4%'");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
<td id="td"><?php echo $row['land'];?></td>
<td id="td2"><?php echo $row['name'];?></td>
</tr> <?php
}
} # end elseif(isset($_POST['search4']))
elseif(isset($_POST['select3'])){
$select3 = $_POST['select3'];
switch($select3){
case 'T1':
$stmt = $db->query("SELECT * FROM users WHERE `zone`='T1'");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
<td id="td"><?php echo $row['land'];?></td>
<td id="td2"><?php echo $row['name'];?></td>
</tr> <?php
}
break; # end case 'T1', more cases follows
} # end switch($select3)
} # end elseif(isset($_POST['select3']))
elseif (isset($_POST['search5'])){
$search5 = $_POST['search5'];
$stmt = $db->query("SELECT * FROM users WHERE `s_a` LIKE '%search5%'");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
<td id="td"><?php echo $row['land'];?></td>
<td id="td2"><?php echo $row['name'];?></td>
</tr><?php
}
} # end elseif(isset($_POST['search5']))
elseif(isset($_POST['select1'])){
$select1 = $_POST['select1'];
switch($select1){
case 'code':
$stmt = $db->query("SELECT * FROM users");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
</tr><?php
}
break; # end case 'code', more cases follows
} # end switch($select1)
} # end elseif(isset($_POST[select1]))
elseif(isset($_POST['select4'])){
$select4 = $_POST['select4'];
switch($select4){
case 1:
$stmt = $db->query("SELECT * FROM users LIMIT 1");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
<td id="td"><?php echo $row['land'];?></td>
<td id="td2"><?php echo $row['name'];?></td>
</tr><?php
}
break; # end case 1, more cases follows
} # end switch($select4)
} # end elseif(isset($_POST['select4'])))
else { # if noone of the select menus or search boxes where filled, then just render all the data from db to the page
$stmt = $db->query("SELECT * FROM users");
while($row = $stmt->fetch_assoc()){ ?>
<tr class="action">
<td id="td"><?php echo $row['code'];?></td>
<td id="td"><?php echo $row['land'];?></td>
<td id="td2"><?php echo $row['name'];?></td>
</tr><?php
}
} # end php script
Sorry for this post beeing so long, but I tried to express as better as I can. The problem is that when I select one option from a select menu, or I enter a term to search, nothing is displayed. I don't care for now if something is missing in my code when comes about security, I just want to make this app work. Any help? Thanks a lot!
LE: I finally found the fix for my problem (and I will write it here so that any other persons that will search for this type of problems, to have an answer (I'll write a trivial example)):
For search-boxes:
<form action="" method="post">
<input type="search" name="search1" onchange="this.form.submit()">
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr><?php
if(isset($_POST['search1'])){
$search1 = $_POST['search1'];
if(!empty($_POST['search1'])){
$sql = "SELECT * FROM tblName WHERE fname LIKE '%$search1%'";
$stmt = $db->query($sql);
while($row = $stmt->fetch_assoc()){ ?>
<tr>
<td><?php echo $row['fname'];?></td>
<td><?php echo $row['lname'];?></td>
</tr><?php
}
}
}
else {
$sql = "SELECT * FROM tblName";
$stmt = $db->query($sql);
while($row = $stmt->fetch_assoc()){ ?>
<tr>
<td><?php echo $row['fname'];?></td>
<td><?php echo $row['lname'];?></td>
</tr><?php
}
} ?>
</table>
</form>
For select-menus:
<form action="" method="post">
<select name="select1" onchange="this.form.submit()">
<option value="">Select</option>
<option value="fname">First Name</option>
<option value="lname">Last Name</option>
</select>
<table>
<tr>
<th>First Name</th>
<th>Last Name</th>
</tr><?php
if(isset($_POST['select1'])){
$select1 = $_POST['select1'];
if(!empty($_POST['select1'])){
switch($select1){
case 'fname':
$stmt = $db->query("SELECT * FROM users");
while($row = $stmt->fetch_assoc()){ ?>
<tr>
<td><?php echo $row['fname'];?></td>
</tr><?php
}
break;
case 'lname':
$stmt = $db->query("SELECT * FROM users");
while($row = $stmt->fetch_assoc()){ ?>
<tr>
<td><?php echo $row['lname'];?></td>
</tr><?php
}
break;
}
}
}
else {
$stmt = $db->query("SELECT * FROM users");
while($row = $stmt->fetch_assoc()){ ?>
<tr>
<td><?php echo $row['fname'];?></td>
<td><?php echo $row['lname'];?></td>
</tr><?php
}
}?>
</table>
</form>
Your sample code is incomplete. The way it is written, many of your search options won't work. I would try selecting select2 and P1. That should work.
But there is potentially a bug in all of your IF statements. You shouldn't just test if a $_POST variable is set, you should make sure it's not NULL or zero length (strlen($var) > 0). Post variables can be "set" but still not have been submitted with actual data.
I would removed everything in your example that isn't related to select2 and see if you can get it to work in a much simpler format.
And of course smashing all of your SQL and PHP code in with a bunch of HTML is a bad idea, but that's not part of the question.
Related
I have an HTML table that gets information fetched from a DB. Using a while loop, all the rows are created depending on the number of user records on the DB. The problem is that only the last row of the table shows the select box.
<table id="UserTable">
<tr bgcolor="#2ECCFA">
<th>UserID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Approval</th>
</tr>
<?php
while ($course = mysqli_fetch_assoc($records)){
echo "<tr>";
echo "<td>".$course['user_id']."</td>";
echo "<td>".$course['first_name']."</td>";
echo "<td>".$course['last_name']."</td>";
echo "<td>".$course['email']."</td>";
}
?>
<td>
<select>
<option value="Approved">Approved</option>
<option value="Dissaproved">Dissaproved</option>
</select>
</td>
</table>
Fix your html as:
<?php
while ($course = mysqli_fetch_assoc($records)){?>
<tr>
<td><?php echo $course['user_id']?></td>
<td><?php echo $course['first_name']?></td>
<td><?php echo $course['last_name']?></td>
<td><?php echo $course['email']?></td>
<td>
<select>
<option value="Approved">Approved</option>
<option value="Dissaproved">Dissaproved</option>
</select>
</td>
</tr>
<?php
}?>
The issue im having is when running a while loop inside of a while loop in php the html content after the second while loop is not being rendered
for a live demonstration http://naturalflame.altervista.org/home.php
I originally didnt use a continue after the second loop but then none of the other rows populate because it just stops after the second loop after adding the continue after the second loop the other rows populate but the description and action field are left out
<div id="main">
<h1>Product List</h1>
<table>
<tr>
<th>Size</th>
<th>Price</th>
<th>Flavor Selection</th>
<th>Flavor Description</th>
<th>Blend Selection</th>
<th>Action</th>
</tr>
<?
$sql="SELECT * FROM products ORDER BY price ASC";
$query=mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_object($query)){
$id = $row->id;
$size = $row->size;
$price = $row->price;
?>
<tr>
<td><? echo $size; ?></td>
<td>$<? echo $price; ?></td>
<td>
<select onchange="ChangeDescription(<? echo $id; ?>)" id="dSelection<? echo $id; ?>">
<option value="Select a flavor">Select a flavor</option>
<?
$sql2 = "SELECT * FROM flavors ORDER BY id ASC";
$query2 = mysql_query($sql2) or die(mysql_error());
while($row2 = mysql_fetch_object($query2)){
$name = $row2->name;
echo "
<option value='$name'>$name</option>
";
}
?>
</select>
</td>
<td id="description<? echo $id; ?>">Flavor Description</td>
<td>Add to cart</td>
</tr>
<?}?>
</table>
</div><!--end main-->
You seem to be using an object as an array causing an error on your page.
This code: $row['id'] is probably just supposed to be $id
If you hadn't of already put it in a placeholder it would be $row->id
So, I am trying to sort a database by clickable links. I have a function that is supposed to order them, but for some reason it isn't working. Also, once I add something to the database and submit, if I click on the links to order, it sends me to my actual function holding file in the url, which is weird.
Forgive table formatting issues. I'm still debugging that.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Project 1</title>
</head>
<body>
<h1 style='text-align:center;'>Movie Collection Database</h1>
<form method='post' action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table align='center' border='1' cellpadding='5'>
<tr>
<td>
<input type="text" size='40' name="movieTitle" value="Movie Title">
</td>
<td>
<input type="text" name="studioName" value="Studio Name">
</td>
<td>
<select name="movieRating">
<option value="G">G</option>
<option value="PG">PG</option>
<option value="PG-13">PG-13</option>
<option value="R">R</option>
<option value="NC-17">NC-17</option>
<option value="Not Rated">Not Rated</option>
</select>
</td>
<td>
<input type="text" name="publicationYear" value="2015">
</td>
<td>
<input type="number" name="imdbRating" value="10.0">
</td>
<td>
<input type="number" name="runTime" value="0">
</td>
<td>
<input type="checkbox" name="add">Add
</td>
</tr>
</table>
<?php
$db = new PDO("mysql:host=localhost;dbname=berkleyr", "berkleyr", "12345");
?>
<?php include_once("Project1DB.php"); ?>
<?php if ($_SERVER['REQUEST_METHOD'] === "POST"):
delete($db);
if(isset($_POST['add']))
{
try
{
Insert($db, $_POST['movieTitle'], $_POST['studioName'], $_POST['movieRating'], $_POST['publicationYear'], $_POST['imdbRating'], $_POST['runTime']);
}
catch (PDOException $error)
{
$db->rollback();
echo "Bad things Happened";
$db = null;
die("Connection failed: " . $error->getMessage());
}
}
?>
<table align='center' border='1'>
<tr>
<th>Title</th>
<th>Studio Name</th>
<th>Rating</th>
<th>Pub Year</th>
<th>IMDB Rating</th>
<th>Run Time</th>
<th>Delete</th>
</tr>
<?php foreach (Select($db) as $row): ?>
<tr>
<td><?php echo $row['title']; ?></td>
<td><?php echo $row['studio']; ?></td>
<td><?php echo $row['rating']; ?></td>
<td><?php echo $row['pub_year']; ?></td>
<td><?php echo $row['imdb_rating']; ?></td>
<td><?php echo $row['run_time']; ?></td>
<?php echo "<td><input type='checkbox' name='". $row['id'] . "' value='" . $row['id'] . "'></td>";?>
</tr>
<?php endforeach ?>
<?php
if (isset($db))
{
$db = null; // make sure an exception didn't already close the connection. If not, close it now.
}
?>
<?php else: ?>
<table align='center' border="1">
<tr>
<th>Title</th>
<th>Studio Name</th>
<th>Rating</th>
<th>Pub Year</th>
<th>IMDB Rating</th>
<th>Run Time</th>
<th>Delete</th>
</tr>
<?php foreach (Select($db) as $row): ?>
<tr>
<td><?php echo $row['title']; ?></td>
<td><?php echo $row['studio']; ?></td>
<td><?php echo $row['rating']; ?></td>
<td><?php echo $row['pub_year']; ?></td>
<td><?php echo $row['imdb_rating']; ?></td>
<td><?php echo $row['run_time']; ?></td>
<?php echo "<td><input type='checkbox' name='". $row['id'] ."' value='" . $row['id'] . "'></td>";?>
</tr>
<?php endforeach ?>
<?php endif ?>
<td colspan="7" align="center">
<input type='submit' name='submit' value='Update Database' />
</td>
</table>
</form>
</body>
</html>
Here is my function for sorting:
function orderBy($order)
{
switch($order)
{
case "title":
$sorted = $this->db->prepare("SELECT * FROM movie ORDER BY movie.title ASC");
break;
case "studio":
$sorted = $this->db->prepare("SELECT * FROM movie ORDER BY movie.studio ASC");
break;
case "rating":
$sorted = $this->db->prepare("SELECT * FROM movie ORDER BY movie.rating ASC");
break;
case "pub_year":
$sorted = $this->db->prepare("SELECT * FROM movie ORDER BY movie.pub_year ASC");
break;
case "imdb_rating":
$sorted = $this->db->prepare("SELECT * FROM movie ORDER BY movie.imdb_rating ASC");
break;
case "run_time":
$sorted = $this->db->prepare("SELECT * FROM movie ORDER BY movie.run_time ASC");
break;
}
$sorted->execute();
}
Im trying to have a simple select box that filters the database. I have successfully filled the database with all vallues on pageload, however I cant seem to get over the final hurdle of applying the filter. Also, once I have clicked the filter button, is it possible for the select text to stay at the text rather than returning to the default text?
[NOTE: I have pretty URL's enabled hence the no .php at the end]
The code is as followed:
<?php
$query = "SELECT * FROM Events";
echo $Type;
if (isset($_POST['filter'])) {
$Type = $_POST['value'];
$query .= " WHERE Type = '{$Type}'";
}
$result = mysql_query($query);
?>
<form action='/events' method="post" name="form_filter" >
<select class="eventList">
<option value="EVENT1">EVENT1</option>
<option value="EVENT2">EVENT2</option>
<option value="EVENT3">EVENT3</option>
<option value="EVENT4">EVENT4</option>
<option value="EVENT5">EVENT5</option>
<option value="EVENT6">EVENT6</option>
<input type="submit" name="filter" value="Filter">
</select>
</form>
<table class="table table-striped table-hover table-curved">
<thead>
<tr>
<th><b>Date</b></th>
<th><b>Event Name</b></th>
<th><b>Type</b></th>
<th><b>Region</b></th>
</tr>
</thead>
<tbody>
<?php while ($row = mysql_fetch_array($result)) { ?>
<tr>
<td><?php echo $Date = $row['Date']; ?></td>
<td><?php echo $Name = $row['Name']; ?></td>
<td><?php echo $Type = $row['Type']; ?></td>
<td><?php echo $Region = $row['Region']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
Your <select> does not have a name:
<select class="eventList" name="event">
Use that name as index in the $_POST array:
$Type = $_POST['event'];
Update your code as follow
<?php
$query = "SELECT * FROM Events";
echo $Type;
if (isset($_POST)) {
$Type = $_POST['event'];
$query .= " WHERE Type = '{$Type}'";
}
$result = mysql_query($query);
?>
<form action='/events' method="post" name="form_filter" >
<select class="eventList" name="event">
<option value="EVENT1" <?php echo ($Type=="EVENT1")?'selected="selected"':'';?>>EVENT1</option>
<option value="EVENT2" <?php echo ($Type=="EVENT2")?'selected="selected"':'';?>>EVENT2</option>
<option value="EVENT3" <?php echo ($Type=="EVENT3")?'selected="selected"':'';?>>EVENT3</option>
<option value="EVENT4" <?php echo ($Type=="EVENT4")?'selected="selected"':'';?>>EVENT4</option>
<option value="EVENT5" <?php echo ($Type=="EVENT5")?'selected="selected"':'';?>>EVENT5</option>
<option value="EVENT6" <?php echo ($Type=="EVENT6")?'selected="selected"':'';?>>EVENT6</option>
<input type="submit" name="filter" value="Filter">
</select>
</form>
<table class="table table-striped table-hover table-curved">
<thead>
<tr>
<th><b>Date</b></th>
<th><b>Event Name</b></th>
<th><b>Type</b></th>
<th><b>Region</b></th>
</tr>
</thead>
<tbody>
<?php while ($row = mysql_fetch_array($result)) { ?>
<tr>
<td><?php echo $Date = $row['Date']; ?></td>
<td><?php echo $Name = $row['Name']; ?></td>
<td><?php echo $Type = $row['Type']; ?></td>
<td><?php echo $Region = $row['Region']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
i have update this line
`if (isset($_POST)) {
and added the select name and code list code
$Type =$_POST['event'];
<select class="eventList" name="event">
<option value="EVENT1" <?php echo ($Type=="EVENT1")?'selected="selected"':'';?>>EVENT1</option>
Good day. Im trying to have some functionality on my project, but im stuck with this.
I want to display my database depending on what the user select
Here is my html code:
<table>
<tr><td>Select Request Status:</td>
<td><select class="form-control" name="status" style="width:200px;">
<option value="1">Pending Request</option>
<option value ="2">Requests On-Process</option>
<option value="3">Unassigned Requests</option>
<option>All Requests</option>
</select></td>
</tr>
</table>
And here is my php code:
if ($status = $_SESSION['status'] == 'Pending Request')
{
$query = "select * from tblrequest where status='Pending Request'";
$request = mysql_query($query)or die(mysql_error());?>
<table class="table">
<tr>
<th>Request ID</th>
<th>Requestor</th>
<th>Department</th>
<th>Category</th>
<th>Assigned to</th>
<th>Status</th>
<th>Created Date</th>
<th>Created Time</th>
</tr>
<?php while($row = mysql_fetch_array($request)){
?>
<tbody class="table table-hover">
<tr>
<td style="width:100px;"><?php echo $row['RequestNumber']; ?></td>
<td style="width:100px;"><?php echo $row['Requestor']; ?></td>
<td style="width:100px;"><?php echo $row['Department']; ?></td>
<td style="width:50px;"><?php echo $row['category']; ?></td>
<td style="width:100px;"><?php echo $row['AssignedTo']; ?></td>
<td style="width:100px;"><?php echo $row['status']; ?></td>
<td style="width:100px;"><?php echo $row['DateRequested']; ?></td>
<td style="width:100px;"><?php echo $row['TimeRequested']; ?></td>
</tr>
</tbody>
<?php
}
}?>
Im a newbie to php so please help me.
Can you try this,
HTML:
<form method="post">
<table>
<tr><td>Select Request Status:</td>
<td>
<?php $Statuses = array("0"=>"All Requests", "1"=>"Pending Request", "2"=>"Requests On-Process", "3"=>"Unassigned Requests" );?>
<select class="form-control" name="status" style="width:200px;" onchange="this.form.submit();">
<?php foreach($Statuses as $key=>$status):?>
<?php
$selected ="";
$statusPost = $_POST['status'];
if($key == $statusPost): $selected =" selected"; endif;
?>
<option value="<?php echo $key;?>" <?php echo $selected;?>><?php echo $status;?></option>
<?php endforeach;?>
</select></td>
</tr>
</table>
</form>
PHP:
if (isset($_POST['status'])){
$status= $_POST['status'];
$Where ='';
if($status!='0'){
$Where =" where status='".$Statuses[$status]."' ;
}
}
$query = "select * from tblrequest $Where";
$request = mysql_query($query)or die(mysql_error());?>
<table class="table">
<tr>
<th>Request ID</th>
<th>Requestor</th>
<th>Department</th>
<th>Category</th>
<th>Assigned to</th>
<th>Status</th>
<th>Created Date</th>
<th>Created Time</th>
</tr>
<?php while($row = mysql_fetch_array($request)){
?>
<tbody class="table table-hover">
<tr>
<td style="width:100px;"><?php echo $row['RequestNumber']; ?></td>
<td style="width:100px;"><?php echo $row['Requestor']; ?></td>
<td style="width:100px;"><?php echo $row['Department']; ?></td>
<td style="width:50px;"><?php echo $row['category']; ?></td>
<td style="width:100px;"><?php echo $row['AssignedTo']; ?></td>
<td style="width:100px;"><?php echo $row['status']; ?></td>
<td style="width:100px;"><?php echo $row['DateRequested']; ?></td>
<td style="width:100px;"><?php echo $row['TimeRequested']; ?></td>
</tr>
</tbody>
<?php
}
?>
put select dropdown in a form with id,action,method etc.
give id to a select element(say "mySelect")
Now, in jquery,
$("#mySelect").on("change",function(){
if($("#mySelect").val() != ""))
{
$("#form1").submit();
}
})