<html>
<head>
<basefont face="Arial">
</head>
<style>
body { background-color: #E6E6FA; }
</style>
<body>
<?php
error_reporting(E_ALL);
if (!isset($_POST['Submit'])) {
// form not submitted
?>
<H3>Search Records Application</H3>
<form action="search.php" method="post">
Search <input type="text" name="search">
<select size="1" name="dropdown">
<option value="" selected>Search By...</option>
<option value="BookID">Book Id</option>
<option value="transactiondate">Transaction Date</option>
<option value="storename">Store Name</option>
<option value="checkdate">Check Date</option>
<option value="datecashed">Date Cashed</option>
<option value="datereturn">Date Return</option>
<option value="checknumber">Check Number</option>
<option value="makername">Maker Name</option>
<option value="payeename">Payee Name</option>
<option value="bankname">Bank Name</option>
<option value="checkamount">Check Amount</option>
<option value="returnreason">Return Reason</option>
<option value="datesolved">Date Solved</option>
<option value="redeposited">Redeposited</option>
<option value="replacement">Replacement</option>
<option value="paidcash">Paid Cash</option>
<option value="balance">Balance</option>
<option value="disposition">Disposition</option>
</select>
<input type="Submit" value="Submit" name="Submit">
</form>
<?php
}
else {
// form submitted
// set server access variables
$host = "localhost";
$user = "root";
$pass = "";
$db = "books";
$search = empty($_POST['search'])? die ("ERROR: Enter Search Criteria") : mysql_escape_string($_POST['search']);
$dropdown = empty($_POST['dropdown'])? die ("ERROR: Select from dropdown") : mysql_escape_string($_POST['dropdown']);
// Open Connection
$connect = mysql_connect($host, $user, $pass) or die ("Unable to connect to host");
//Select Database
mysql_select_db($db) or die ("Unable to connect to database");
//Create Query
$query = "SELECT * FROM books WHERE $dropdown='$search'" or die (mysql_error());
$result = mysql_query($query) or die (mysql_error());
$num=mysql_numrows($result);
mysql_close($connect);
echo "<b><center>Search Results of Bounced Checks</center></b><br><br>";
$i=0;
while ($i < $num) {
$bookid=mysql_result($result,$i,"bookid");
$transactiondate=mysql_result($result,$i,"transactiondate");
$storename=mysql_result($result,$i,"storename");
$checkdate=mysql_result($result,$i,"checkdate");
$datecashed=mysql_result($result,$i,"datecashed");
$datereturn=mysql_result($result,$i,"datereturn");
$checknumber=mysql_result($result,$i,"checknumber");
$makername=mysql_result($result,$i,"makername");
$payeename=mysql_result($result,$i,"payeename");
$bankname=mysql_result($result,$i,"bankname");
$checkamount=mysql_result($result,$i,"checkamount");
$returnreason=mysql_result($result,$i,"returnreason");
$datesolved=mysql_result($result,$i,"datesolved");
$redeposited=mysql_result($result,$i,"redeposited");
$replacement=mysql_result($result,$i,"replacement");
$paidcash=mysql_result($result,$i,"paidcash");
$balance=mysql_result($result,$i,"balance");
$disposition=mysql_result($result,$i,"disposition");
echo "<table width = '1000' align = 'center' border ='1'>";
echo ("<tr><td>Check ID</td><td>Transaction Date</td><td>Store Name</td><td> Check Date</td><td>Date Cashed</td><td>Date Return</td><td>Check Number</td><td>Maker Name</td><td>Payee Name</td><td>Bank Name</td><td>Check Amount</td><td>Return Reason</td><td>Date Solved</td><td>Redeposited</td><td>Replacement</td><td>Paid Cash</td><td>Balance</td><td>Disposition</td></tr>");
echo "</b></tr>";
echo "<tr>";
echo "<td>".$bookid."</td>";
echo "<td>".$transactiondate."</td>";
//if you want the full date replace the $year_part_of_date[0] with $record->date
echo "<td>".$storename."</td>";
echo "<td>".$checkdate."</td>";
echo "<td>".$datecashed."</td>";
echo "<td>".$datereturn."</td>";
echo "<td>".$checknumber."</td>";
echo "<td>".$makername."</td>";
echo "<td>".$payeename."</td>";
echo "<td>".$bankname."</td>";
echo "<td>".$checkamount."</td>";
echo "<td>".$returnreason."</td>";
echo "<td>".$datesolved."</td>";
echo "<td>".$redeposited."</td>";
echo "<td>".$replacement."</td>";
echo "<td>".$paidcash."</td>";
echo "<td>".$balance."</td>";
echo "<td>".$disposition."</td>";
echo "</tr>";
echo "</table>";
$i++;
}
}
?>
</body>
</html>
tonyfonseca 0 Newbie Poster
pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster
tonyfonseca 0 Newbie Poster
adam.adamski.96155 43 Junior Poster
tonyfonseca 0 Newbie Poster
Bachu 45 Newbie Poster
tonyfonseca 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.