Search data table with Date - php

I have a data table which is the result of one form submission, the form has start_date and end_date where its type is DATETIME-LOCAL.
In my database its DATETIME (not showing AM and PM),
I want to add search function to my data table based on the date not date and time,
Other type of search based on TYPE and NAME are working but date doesn't show nor error and results.
<form action="search.php" id="searchform" method="POST" class="searchbox-container">
<input type="text" id="searchbox" placeholder="Search" name="searchbox" class="searchbox" />
<input type="date" name="date">
<select name="select" id="select">
<option value="type">Type</option>
<option value="name">Name</option>
</select>
<input type="submit" name="search" class="searchbox-btn" value="Go" />
</form>
<?php
if(isset($_POST['search'])){
$search=preg_replace('#[^a-z 0-9?!]#i','',$_POST['searchbox']);
$user="admin";
$pass="neehahs";
$host="localhost";
$db_name="eventregisteration";
$con=mysqli_connect($host, $user, $pass, $db_name);
if(mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$date=$_POST['date'];
if($_POST['select']=="type"){
$sqlcommand="SELECT * FROM eventform WHERE event_type LIKE '%$search%'";
}
elseif($_POST['select']=="name"){
$sqlcommand="SELECT * FROM eventform WHERE event_name LIKE '%$search%'";
}
else {
if($date!=0)
$sqlcommand="SELECT * FROM eventform WHERE start_date='$date' ORDER BY start_date DESC";
}
$sqldata=mysqli_query($con,$sqlcommand)
or die("Error Getting Data");
$count=mysqli_num_rows($sqldata);
if($count!=0){
echo "<table border=2 bordercolor=#440000 cellpadding=2 bgcolor=#DDDDDD width=100%>";
echo "<tr bgcolor=#555555 style=font-size:18px align=center><th>Event Code</th><th>Event Name</th><th>Event Type</th><th>Event Level</th><th>Start Date</th>
<th>End Date</th><th>Point</th><th>Picture</th><th>Video</th><th>Description</th></tr>";
while($row=mysqli_fetch_array($sqldata)){
echo "<tr align=center><td>";
echo $row['event_code'];
echo "</td><td>";
echo $row['event_name'];
echo "</td><td>";
echo $row['event_type'];
echo "</td><td>";
echo $row['event_level'];
echo "</td><td>";
echo $row['start_date'];
echo "</td><td>";
echo $row['end_date'];
echo "</td><td>";
echo $row['points'];
echo "</td><td>";
echo "".$row['pic']."";
echo "</td><td>";
echo "".$row['video']."";
echo "</td><td>";
echo $row['description'];
echo "</td></tr>";
}
echo "</table>";
}else{
echo "hi";
$search_output="<hr/>0 Results for<strong>$search</strong><hr/>";
}
}
?>

Your query written in an index-friendly manner might look like this
SELECT *
FROM eventform
WHERE start_date >= '$date'
AND start_date < '$date' + INTERVAL 1 DAY
ORDER BY start_date DESC
where $date should be in YYYY-MM-DD format (e.g. 2013-11-27)
Here is SQLFiddle demo
On a side note: since you already using mysqli consider to learn and use prepared statements instead of interpolating query strings leaving it wide open to sql injections.

Related

Populate dropdownlist php with separate sql query

I have a form that allows users to update their client's transactions. This form comes populated with the information already listed for the transaction. I want to have a drop down list for the customer names so that they have to choose an existing customer.
My problem is that the sql to populate the answers with the existing information conflicts with the sql to bring up the customer names in the database.
Is there a way to do this? Here is the code I have that brings up the populated answers:
<table>
<?php
if (!isset ($p_submitval))
{
$sql = "SELECT crid, c.custid,
firstname, lastname, cramount, crdate
FROM databau7_thomand.customer
c inner join databau7_thomand.cashrec r on
c.custid = r.custid WHERE crid= " .
$p_crid;
$result = mysqli_query($con, $sql);
while($row =
mysqli_fetch_array($result))
echo "<h2>Update Customer
Information</h2>\n";
echo "<p><i>Please update the customer information.</i><br>\n";
echo "<form action=\"web4_transactioninput.php\" method=post>\n";
echo "<input type=\"hidden\" name=\"crid\" value = \"$p_crid\">\n";
echo "<table border=\"3\"> \n";
echo "<td align=\"right\"><b>Customer Name:
</td>";
echo "<td><select name=\"custid\"
class=\"dropdown\">";
echo "<option value=\"0\" selected>
".$row['firstname']." ".$row['lastname']."
</option>\"";
echo "<tr>\n<td align=\"right\">\n";
echo "<b>Amount:</b>\n";
echo "</td>\n<td>\n";
echo "<input type=\"text\"
name=\"cramount\"size=\"30\"
value=\"".$row['cramount']."\">\n";
echo "</td>\n</tr>\n";echo "<tr>\n<td
align=\"right\">\n";
echo "<b>Date:</b>\n";
echo "</td>\n<td>\n";
echo "<input type=\"date\"
name=\"crdate\"size=\"30\"
value=\"".$row['crdate']."\">\n";
echo "</td>\n</tr>\n";echo "<tr>\n<td
align=\"right\">\n";
}
while($row =
mysqli_fetch_array($result))
echo "</select>\n</td>\n</tr>\n";
echo "</table>\n";
Thank you for the help!
Remove ALLLLLL the echo "..."; for html portion as you don't need it. Just a recommendation. Much cleaner view and unnecessary
You also should be using prepared statements as inserting a variable a parameter is unsafe.
This is a really rough example, but check it out this way:
<table>
<?php
if (!isset ($p_submitval)){
$sql = "
SELECT crid
, c.custid
, firstname
, lastname
, cramount
, crdate
FROM databau7_thomand.customer c
JOIN databau7_thomand.cashrec r
on c.custid = r.custid
WHERE crid= ?;
";
$stmt = $con->prepare($sql);
$stmt->bind_param("s",$p_crid);
$stmt->execute();
$stmt->bind_result($crid,$custid,$fname,$lname,$cramount,$crdate);
$stmt->store_result();
?>
<h2>Update Customer
Information</h2>";
<p><i>Please update the customer information.</i><br>
<form action="web4_transactioninput.php" method=post>
<input type="hidden" name="crid" value = "<?php echo $p_crid;?>">
<table border="3">
<td align="right"><b>Customer Name: </td>
<td><select name="custid" class="dropdown">";
<?php
echo "<option value=\"0\" selected> $fname $lname</option>";
?>'
<tr><td align="right">
<b>Amount:</b>
</td><td>
<input type="text" name="cramount"size="30" value="<?php echo $cramount;?>">;
<?php
$stmt->close();
}

how to display auto increment data form mysql in php

In my university database project I have an auto increment field roll number in my SQL. What I want is that when new admission take place and a student record is inserted it displays all finds on same page including roll number. However despite my best efforts all it returns 0 in roll number.
Here is the code:
<?php
$con = mysqli_connect("localhost", "root", "") or die("conection error");
mysqli_select_db($con, "hamdard university") or die("dbase error");
if (isset($_POST['subbtn'])) {
$r = "SELECT RollNo FROM admission_form";
$result = mysqli_query($con, $r);
if (mysqli_query($con, $r)) {
$last_id = mysqli_insert_id($con);
}
$n = $_POST['txtname'];
$f = $_POST['txtfac'];
$s = $_POST['txtsem'];
$sql = "insert into admission_form(name,faculty,semester)values ('$n','$f','$s')";
mysqli_query($con, $sql);
echo "<table border=1>
<th>RollNo</th>
<th>Name</th>
<th>Faculty</th>
<th>Semester</th>";
echo "<tr>";
echo "<td>";
echo $last_id;
echo "</td>";
echo "<td>";
echo $n;
echo "</td>";
echo "<td>";
echo $f;
echo "</td>";
echo "<td>";
echo $s;
echo "</td>";
echo "<br>";
}
?>
<html>
<head></head>
<body>
<form name="f1" action="" method="POST">
RollNo:
<input type="text" name="txtroll" readonly> Name:
<input type="text" name="txtname"> Faculty:
<input type="text" name="txtfac"> Semester:
<input type="text" name="txtsem">
<input type="submit" value="done" name="subbtn">
</form>
</body>
</html>
You need get $last_id after INSERT query
$sql="insert into admission_form(name,faculty,semester)values ...
mysqli_query($con,$sql);
$last_id = mysqli_insert_id($con);
You have misplaced insert query. Change it as:
<?php
$con=mysqli_connect("localhost","root","")or die("conection error");
mysqli_select_db($con,"hamdard university")or die("dbase error");
if(isset($_POST['subbtn']))
{
$sql="insert into admission_form(name,faculty,semester)values ('$n','$f','$s')";
if (mysqli_query($con, $sql))
{
$last_id = mysqli_insert_id($con);
}
$n=$_POST['txtname'];
$f=$_POST['txtfac'];
$s=$_POST['txtsem'];
$r="SELECT RollNo FROM admission_form";
$result=mysqli_query($con, $r);
echo "<table border=1>
<th>RollNo</th>
<th>Name</th>
<th>Faculty</th>
<th>Semester</th>";
echo "<tr>";
echo "<td>";
echo $last_id;
echo "</td>";
echo "<td>";
echo $n;
echo "</td>";
echo "<td>";
echo $f;
echo "</td>";
echo "<td>";
echo $s;
echo "</td>";
echo "<br>";
}
?>
<html>
<head></head>
<body>
<form name="f1" action="" method="POST">
RollNo:<input type="text" name="txtroll" readonly>
Name:<input type="text" name="txtname">
Faculty:<input type="text" name="txtfac">
Semester:<input type="text" name="txtsem">
<input type="submit" value="done" name="subbtn">
</form>
</body>
</html>
You have some problems in this page.
As stated before, the INSER query must be before the select.
If you do "SELECT RollNo FROM admission_form" you will get ALL existing RollNo in admission_form and not the lastest one. If this is an int with auto increment (that seams to be) you should do "SELECT max(RollNo) FROM admission_form".
You don't need to do the above select, as mysqli_insert_id get the ID inserted in the last query.
You might not see the result in your table because it is on HTML head, but it should be in the body of the page.
The table you create is not "closed".
You should be good to go with the code bellow.
<HTML>
<HEAD></HEAD>
<BODY>
<?php
$con=mysqli_connect("localhost","root","")or die("conection error");
mysqli_select_db($con,"hamdard university")or die("dbase error");
if(isset($_POST['subbtn']))
{
$n=$_POST['txtname'];
$f=$_POST['txtfac'];
$s=$_POST['txtsem'];
$sql="insert into admission_form(name,faculty,semester) values ('$n','$f','$s')";
if (mysqli_query($con, $r))
{
$last_id = mysqli_insert_id($con);
}
echo "<table border=\"1\"><th>RollNo</th> <th>Name</th> <th>Faculty</th> <th>Semester</th>";
echo "<tr>";
echo "<td>";
echo $last_id;
echo "</td>";
echo "<td>";
echo $n;
echo "</td>";
echo "<td>";
echo $f;
echo "</td>";
echo "<td>";
echo $s;
echo "</td>";
echo "</tr></table>";
}
?>
<form name="f1" action="" method="POST">
RollNo:<input type="text" name="txtroll" readonly>
Name:<input type="text" name="txtname">
Faculty:<input type="text" name="txtfac">
Semester:<input type="text" name="txtsem">
<input type="submit" value="done" name="subbtn">
</form>
</body>
</html>
Try this:
$mysqli = new mysqli(SQLI_SERVER, MYSQLI_USER, MYSQLI_PWD, MYSQLI_DBNAME);
if ($result = $mysqli->query("INSERT INTO admission_form(name, facility,semester) VALUES..) {
echo 'The ID is: '.$mysqli->insert_id;
}

Search Data not outputting the correct results

This form is a search form which allows the user to search for an event using the Venue and category fields which are scripted as dropdown boxes and the Price and event title as user input text boxes, as shown via the code if a keyword is entered which matches the fields on the database it should output all the related information for that event if any matches have been made on either search fields, the tickboxes allow the user to identify what criteria they would like to search with, if the tickbox field hasn't been checked then the SQL enquiry will not search for keywords with that corresponding field.
The issue is, it all seems to work fine except no results seem to show up for the Venue and Category fields if they was solely used to search for an event. But if I choose another field everything is outputting correctly including the venue and Category field.
DATABASE: http://i.imgur.com/d4uoXtE.jpg
HTML FORM
<form name="searchform" action ="PHP/searchfunction.php" method = "post" >
<h2>Event Search:</h2>
Use the Check Boxes to indicate which fields you watch to search with
<br /><br />
<h2>Search by Venue:</h2>
<?php
echo "<select name = 'venueName'>";
$queryresult2 = mysql_query($sql2) or die (mysql_error());
while ($row = mysql_fetch_assoc($queryresult2)) {
echo "\n";
$venueID = $row['venueID'];
$venueName = $row['venueName'];
echo "<option value ='$venueName'";
echo ">$venueName</option>";
}# when the option selected matches the queryresult it will echo this
echo "</select>";
echo" <input type='checkbox' name='S_venueName'>";
mysql_free_result($queryresult2);
mysql_close($conn);
?>
<br /><br />
<h2>Search by Category:</h2>
<?php
include 'PHP/database_conn.php';
$sql3 ="SELECT catID, catDesc
FROM te_category";
echo "<select name = 'catdesc'>";
$queryresult3 = mysql_query($sql3) or die (mysql_error());
while ($row = mysql_fetch_assoc($queryresult3)) {
echo "\n";
$catID = $row['catID'];
$catDesc = $row['catDesc'];
echo "<option value = '$catDesc'";
echo ">$catDesc </option>";
}
echo "</select>";
mysql_free_result($queryresult3);
mysql_close($conn);
?>
<input type="checkbox" name="S_catDes">
<br /><br />
<h2>Search By Price</h2>
<input type="text" name="S_price" />
<input type="checkbox" name="S_CheckPrice">
<br /><br />
<h2>Search By Event title</h2>
<input type="text" name="S_EventT" />
<input type="checkbox" name="S_EventTitle">
<br /><br />
<input name="update" type="submit" id="update" value="Search">
</form>
PHP CODE THAT DEALS WITH PROCESSING THE FORM DATA
<?php
include 'database_conn.php';
$venuename = $_POST['venueName']; //this is an integer
$catdesc = $_POST['catdesc']; //this is a string
$Price = $_POST['S_price'];
$EventT = $_POST['S_EventT'];
#the IF statements state if the tickbox is checked then search with these enquires
if (isset($_POST['S_VenueName'])) {
$sql = "SELECT * FROM te_venue WHERE venueName= '$venuename'";
}
if (isset($_POST['S_catDes'])) {
$sql = "SELECT * FROM te_category WHERE catID= '$catdesc'";
}
if (isset($_POST['S_CheckPrice'])) {
$sql = "SELECT * FROM te_events WHERE (eventPrice LIKE '%$Price%')";
}
if (isset($_POST['S_EventTitle'])) {
$sql = "SELECT * FROM te_events WHERE (eventTitle LIKE '%$EventT%')";
}
$queryresult = mysql_query($sql) or die (mysql_error());
while ($row = mysql_fetch_assoc($queryresult))
{
echo "Event Title: "; echo $row['eventTitle'];
echo "<br />";
echo "Event Description: "; echo $row['eventDescription'];
echo "<br />";
echo "Event Venue "; echo "$venuename";
echo "<br />";
echo "Event Category "; echo "$catdesc";
echo "<br />";
echo "Event Start Date "; echo $row['eventStartDate'];
echo "<br />";
echo "Event End Date "; echo $row['eventEndDate'];
echo "<br />";
echo "Event Price "; echo $row['eventPrice'];
echo "<br /><br />";
}
mysql_free_result($queryresult);
mysql_close($conn);
?>
Try using atleast MySQLi instead of deprecated MySQL. You can try this:
database_conn.php:
<?php
/* ESTABLISH YOUR CONNECTION. REPLACE THE NECESSARY DATA BELOW */
$con=mysqli_connect("YourHost","YourUsername","YourPassword","YourDatabase");
if(mysqli_connect_errno()){
echo "Error".mysqli_connect_error();
}
?>
HTML Form:
<html>
<body>
<?php
include 'PHP/database_conn.php';
$sql2="SELECT venueID, venueName FROM te_venue"; /* PLEASE REPLACE THE NECESSARY DATA */
echo "<select name = 'venueName'>";
$queryresult2 = mysqli_query($con,$sql2);
while($row = mysqli_fetch_array($queryresult2)) {
echo "\n";
$venueID = mysqli_real_escape_string($con,$row['venueID']);
$venueName = mysqli_real_escape_string($con,$row['venueName']);
echo "<option value ='$venueName'>";
echo $venueName."</option>";
} /* when the option selected matches the queryresult it will echo this ?? */
echo "</select>";
echo "<input type='checkbox' name='S_venueName'>";
?>
<br><br>
<h2>Search by Category:</h2>
<?php
$sql3 ="SELECT catID, catDesc FROM te_category";
echo "<select name = 'catdesc'>";
$queryresult3 = mysqli_query($con,$sql3);
while($row = mysqli_fetch_array($queryresult3)) {
echo "\n";
$catID = mysqli_real_escape_string($con,$row['catID']);
$catDesc = mysqli_real_escape_string($con,$row['catDesc']);
echo "<option value = '$catDesc'>";
echo $catDesc."</option>";
}
echo "</select>";
?>
<input type="checkbox" name="S_catDes">
<br><br>
<h2>Search By Price</h2>
<input type="text" name="S_price" />
<input type="checkbox" name="S_CheckPrice">
<br><br>
<h2>Search By Event title</h2>
<input type="text" name="S_EventT" />
<input type="checkbox" name="S_EventTitle">
<br><br>
<input name="update" type="submit" id="update" value="Search">
</form>
</body>
</html>
PHP:
<?php
include 'database_conn.php';
$venuename = mysqli_real_escape_string($con,$_POST['venueName']); /* this is an integer */
$catdesc = mysqli_real_escape_string($con,$_POST['catdesc']); /* this is a string */
$Price = mysqli_real_escape_string($con,$_POST['S_price']);
$EventT = mysqli_real_escape_string($con,$_POST['S_EventT']);
/* SHOULD PRACTICE USING ESCAPE_STRING TO PREVENT SOME OF SQL INJECTIONS */
/* the IF statements state if the tickbox is checked then search with these enquires */
if (isset($_POST['S_VenueName'])) {
$sql = "SELECT * FROM te_venue WHERE venueName= '$venuename'";
}
if (isset($_POST['S_catDes'])) {
$sql = "SELECT * FROM te_category WHERE catID= '$catdesc'";
}
if (isset($_POST['S_CheckPrice'])) {
$sql = "SELECT * FROM te_events WHERE (eventPrice LIKE '%$Price%')";
}
if (isset($_POST['S_EventTitle'])) {
$sql = "SELECT * FROM te_events WHERE (eventTitle LIKE '%$EventT%')";
}
$queryresult = mysqli_query($con,$sql);
while ($row = mysqli_fetch_array($queryresult))
{
echo "Event Title: "; echo $row['eventTitle'];
echo "<br />";
echo "Event Description: "; echo $row['eventDescription'];
echo "<br />";
echo "Event Venue "; echo "$venuename";
echo "<br />";
echo "Event Category "; echo "$catdesc";
echo "<br />";
echo "Event Start Date "; echo $row['eventStartDate'];
echo "<br />";
echo "Event End Date "; echo $row['eventEndDate'];
echo "<br />";
echo "Event Price "; echo $row['eventPrice'];
echo "<br /><br />";
}
mysqli_close($conn);
?>
What if user checks all the check box? What would happen is, the last condition will be used. The first three conditions will be overwritten by the last condition.
If you use ELSE IF in those conditions, the first condition will be implemented.
My advice is to use radio button instead of check box and hope you gets the idea along the way.
Have you tried printing out your $sql query for debugging?
Try <input type="checkbox" name="S_catDes" value="checked">.
From memory checkboxes need a value field but I could be wrong. Hope this helps.

PHP Datepicker in SQL query

so I have this page that shows today's matches by default, it has this datepicker form
<form method="post">
<p> Select Date:<input id="datepicker" type="text" size="8" /> </p>
<input type="submit" value="Submit" name="usub" />
</form>
<?php
if(isset($_POST["usub"])){ $date = $_POST["datepicker"]; }
else{ $date = date('Y-m-d'); }
$data = mysql_query("SELECT * FROM todaysmatches where matchdate='$date'") or die(mysql_error());
echo $_POST["usub"];
echo "<h4>$today Matches</h4> </br>";
//table
if (mysql_num_rows($data)==0){
echo " No Matches";
echo "</br>";
echo "<h4> Sorry About That Check For other Days Or you can Check the Library</h4>";
}
else{
echo "<table border='1'>
<tr>
<th>Match</th>
<th>Tourmanet</th>
<th>Date</th>
</tr>";
while($info = mysql_fetch_array( $data ))
{
echo "<tr>";
echo "<td>" . $info['curmatch'] . "</td>";
echo "<td>" . $info['tournamentname'] . "</td>";
echo "<td>" . $info['matchdate'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
?>
what I want is if the user choose a date in the form it would go in the query and bring the data associated with that date while keeping today as the default one when they first load the page
You need to quote the datevalue in the query as
SELECT * FROM todaysmatches where matchdate= '$today'
$data = mysql_query("SELECT * FROM todaysmatches where matchdate='$today'")
Now to get the datepicker value you need to change a bit in the form and use name attributes as
<form method="post">
<p> Select Date:<input id="datepicker" type="text" size="8" name="datepicker"/> </p>
<input type="submit" value="Submit" name="usub"/>
</form>
Then in PHP you have do as
if(isset($_POST["usub"])){
$date = $_POST["datepicker"];
}
And use it in the query and in the else part you can have the query to get the data from today's date
NOTE : Make sure that the date you are passing from date picker to query is in proper format.

Drop down list filter triggered by submit button

I have made a filter function but I am having trouble with the starting table, I want all the data selected from a table to be displayed if no category is selected for the filter. So far, I can show all the necessary data needed if a category is chosen but only if a category is chosen. If none is chosen, it shows a blank table. Help please,...
Here's the function
function listhistoryHost(){
$accountid=$_SESSION['userid'];
if(isset($_POST['button'])){
$filter=$_POST['historyfilter'];
if($filter==$filter){
$sql="select * from webhostrequest where status='$filter' order by webhostrequest.recentact desc";
$result=mysql_query($sql) or die("Error in selecting items ".mysql_error());
$out="<ul>";
while($row=mysql_fetch_array($result)){
$accountid=$row['userid'];
$requesttitle=$row['requesttitle'];
$requestid=$row['requestid'];
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\">";
echo "<tr class=\"rowcolor1\">";
echo "<td width=\"70%\"><span style=\"padding-left:20px\">Requested Web Hosting for ".$row["requesttitle"]. "</td>";
echo "<td width=\"20%\"><span style=\"padding-left:20px\">Status: " .$row["status"]. "</td>";
echo "<td>
<center>
<form id = \"form1\" method = \"post\" action = \"viewhistorywebhost.php?webhost=$requestid\">
<input type = \"submit\" name = \"button\" id = \"button\" value = \"Details\" />
</form>
</center>";
echo "</tr>";
}
echo "</table>";
return $out;
}
}
}
Here's the form and trigger
<form id = "form1" method = "post" action = "#">
<select id="select1" name="historyfilter">
<option value='' selected disabled>Select item type</option>
<?php
$options = array('approved' => 'Approved',
'cancelled'=>'Cancelled',
'rejected' => 'Rejected');
foreach($options as $value => $type){
echo "<option value=\"$value\">$type</option>";
}
?>
</select>
<input type = "submit" name = "button" id = "submit" value = "Go" />
</form>
<?php
$webhost=new requisition2();
echo $webhost->listhistoryHost();
?>
Just put if condition for query
function listhistoryHost(){
$accountid=$_SESSION['userid'];
if(isset($_POST['button'])){
$filter=$_POST['historyfilter'];
$sql="select * from webhostrequest order by webhostrequest.recentact desc";
if(isset($filter))
$sql="select * from webhostrequest where status='$filter' order by webhostrequest.recentact desc";
$result=mysql_query($sql) or die("Error in selecting items ".mysql_error());
$out="<ul>";
while($row=mysql_fetch_array($result)){
$accountid=$row['userid'];
$requesttitle=$row['requesttitle'];
$requestid=$row['requestid'];
echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\">";
echo "<tr class=\"rowcolor1\">";
echo "<td width=\"70%\"><span style=\"padding-left:20px\">Requested Web Hosting for ".$row["requesttitle"]. "</td>";
echo "<td width=\"20%\"><span style=\"padding-left:20px\">Status: " .$row["status"]. "</td>";
echo "<td>
<center>
<form id = \"form1\" method = \"post\" action = \"viewhistorywebhost.php?webhost=$requestid\">
<input type = \"submit\" name = \"button\" id = \"button\" value = \"Details\" />
</form>
</center>";
echo "</tr>";
}
echo "</table>";
return $out;
}
}
You need to check out a $filter for empty
if (empty($filter)) {
$sql="select * from webhostrequest order by webhostrequest.recentact desc";
} else {
$sql="select * from webhostrequest where status='$filter' order by webhostrequest.recentact desc";
}

Categories