Location: PHPKode > scripts > PHP Online Invoice System > php-online-invoice-system/inv_search.php
<?PHP
/*
 * Exemplar Web hosting
 * http://www.exemplar.biz
 *
 * Title: PHP Online Invoice System
 * Version: 2.0
 * Author: Exemplar
 * Date: 01-01-2006
 *                 
*/

include('header.php');
?>

<h1>Search Invoices for Descriptions or Purchase Order #</h1> 
<form name="search" method="post" action="<?=$PHP_SELF?>">
<B>Seach for: </B><input type="text" name="find" />&nbsp;&nbsp;
<input type="hidden" name="fielda" value="id">
<input type="hidden" name="fieldb" value="note">
<input type="hidden" name="fieldc" value="purchaseorder">
<input type="hidden" name="field" value="serv1desc">
<input type="hidden" name="field1" value="serv1desc">
<input type="hidden" name="field2" value="serv2desc">
<input type="hidden" name="field3" value="serv3desc">
<input type="hidden" name="field4" value="serv4desc">
<input type="hidden" name="field5" value="serv5desc">
<input type="hidden" name="field6" value="serv6desc">
<input type="hidden" name="field7" value="serv7desc">
<input type="hidden" name="field8" value="serv8desc">
<input type="hidden" name="field9" value="serv9desc">
<input type="hidden" name="field10" value="serv10desc">

<input type="hidden" name="searching" value="yes" />
<input class="form-button" type="submit" name="search" value="Search" />
</form>
<?
if ($searching !="yes") 
{
include('footer.php');
} 
//This is only displayed if they have submitted the form 
if ($searching =="yes") 
{ 
echo "<br><br><br><h2>Results</h2><p>"; 

//If they did not enter a search term we give them an error 
if ($find == "") 
{ 
echo "<p>You forgot to enter a search term"; 
exit; 
} 

// We preform a bit of filtering 
$find = strtoupper($find); 
$find = strip_tags($find); 
$find = trim ($find); 


echo "<table width=95% border=1 cellspacing=3 cellpadding=2 bordercolor=cccccc>";
echo "<tr><td class=topHeadrow5 align=\"center\"><b>Invoice #</b></td>
<td class=topHeadrow5 align=\"center\"><b>Invoice Date</b></td>
<td class=topHeadrow5 align=\"center\"><b>Due Date</b></td>
<td class=topHeadrow5 colspan=10 align=\"center\"><b>Descriptions 1 thru 10</b></td>

<td class=topHeadrow5 align=\"center\">Note</td>
<td class=topHeadrow5 align=\"center\">&nbsp;</td>
<td class=topHeadrow5 align=\"center\">&nbsp;</td></tr>";

//Now we search for our search term, in the field the user specified 
$result = mysql_query("SELECT * FROM invoices 
WHERE upper($field) LIKE'%$find%'
 OR upper($field1) LIKE'%$find%'
 OR upper($field2) LIKE'%$find%'
 OR upper($field3) LIKE'%$find%'
 OR upper($field4) LIKE'%$find%'
 OR upper($field5) LIKE'%$find%'
 OR upper($field6) LIKE'%$find%'
 OR upper($field7) LIKE'%$find%'
 OR upper($field8) LIKE'%$find%'
 OR upper($field9) LIKE'%$find%'
 OR upper($field10) LIKE'%$find%'
 OR upper($fielda) LIKE'%$find%'
 OR upper($fieldb) LIKE'%$find%'
 OR upper($fieldc) LIKE'%$find%'
 ORDER BY id ASC
"); 

//And we display the results 
while ($row = mysql_fetch_array($result)) 
{
	
    $invoiceid = $row["id"];
	$clientid = $row["clientid"];
	$client_title = $row["company"];
	$date = $row["date"];
	$bill_date = $row["bill_date"];
	$due_date = $row["due_date"];
	$paid_date = $row["paid_date"];
	$dateshow = fixDate($date);
	$dateshow1 = fixDate($bill_date);
	$dateshow2 = fixDate($due_date);
	$dateshow3 = fixDate($paid_date);
	$dateshow4 = fixdate($today);
	$shipping = $row["shipping"];
	$salestax = $row["salestax"];
	$subtotal = $row["subtotal"];
	$total = $row["total"];
	$misc = $row["misc"];
	$note = $row["note"];
	$status = $row["status"];
	$purchaseorder=$row["purchaseorder"];
	$taxid = $row["taxid"];
	$first_name = $row["first_name"];
    $last_name = $row["last_name"];
    $company = $row["company"];
    $address = $row["address"];
    $city = $row["city"];
    $state = $row["state"];
    $zip = $row["zip"];
    $shiptoname = $row["shiptoname"];
    $shiptoaddr = $row["shiptoaddr"];
    $shiptocity = $row["shiptocity"];
    $shiptostate = $row["shiptostate"];
    $shiptozip = $row["shiptozip"];
    
    $serv1qty = $row["serv1qty"];
    $serv1desc = $row["serv1desc"];
    $serv1amt = $row["serv1amt"];
    $serv1tax = $row["serv1tax"];
    $serv1rate = $row["serv1rate"];
    
    $serv2qty = $row["serv2qty"];
    $serv2desc = $row["serv2desc"];
    $serv2amt = $row["serv2amt"];
    $serv2tax = $row["serv2tax"];
    $serv2rate = $row["serv2rate"];
    
    $serv3qty = $row["serv3qty"];
    $serv3desc = $row["serv3desc"];
    $serv3amt = $row["serv3amt"];
    $serv3tax = $row["serv3tax"];
    $serv3rate = $row["serv3rate"];
    
    $serv4qty = $row["serv4qty"];
    $serv4desc = $row["serv4desc"];
    $serv4amt = $row["serv4amt"];
    $serv4tax = $row["serv4tax"];
    $serv4rate = $row["serv4rate"];
    
    $serv5qty = $row["serv5qty"];
    $serv5desc = $row["serv5desc"];
    $serv5amt = $row["serv5amt"];
    $serv5tax = $row["serv5tax"];
    $serv5rate = $row["serv5rate"];
    
    $serv6qty = $row["serv6qty"];
    $serv6desc = $row["serv6desc"];
    $serv6amt = $row["serv6amt"];
    $serv6tax = $row["serv6tax"];
    $serv6rate = $row["serv6rate"];
    
    $serv7qty = $row["serv7qty"];
    $serv7desc = $row["serv7desc"];
    $serv7amt = $row["serv7amt"];
    $serv7tax = $row["serv7tax"];
    $serv7rate = $row["serv7rate"];
    
    $serv8qty = $row["serv8qty"];
    $serv8desc = $row["serv8desc"];
    $serv8amt = $row["serv8amt"];
    $serv8tax = $row["serv8tax"];
    $serv8rate = $row["serv8rate"];
    
    $serv9qty = $row["serv9qty"];
    $serv9desc = $row["serv9desc"];
    $serv9amt = $row["serv9amt"];
    $serv9tax = $row["serv9tax"];
    $serv9rate = $row["serv9rate"];
    
    $serv10qty = $row["serv10qty"];
    $serv10desc = $row["serv10desc"];
    $serv10amt = $row["serv10amt"];
    $serv10tax = $row["serv10tax"];
    $serv10rate = $row["serv10rate"];
    
	
	if ($alternate == "1") { 
	$color = "#ffffff"; 
	$alternate = "2"; 
	} 
	else { 
	$color = "#dedede"; 
	$alternate = "1"; 
	}
	$textcolor= "#000080";
	 
	echo "<tr valign=top bgcolor=$color><td align=\"center\"><font color=$textcolor>$invoiceid</font></td>
	<td align=\"center\" NOWRAP>$dateshow</td>
	<td align=\"center\" NOWRAP>$dateshow2</td>";
if($serv1desc != ""){
	echo "<td align=\"center\"><font color=$textcolor>$serv1desc</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}
if($serv2desc != ""){
	echo "<td align=\"center\"><font color=$textcolor>$serv2desc</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}
if($serv3desc != ""){
	echo "<td align=\"center\"><font color=$textcolor>$serv3desc</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}
if($serv4desc != ""){
	echo "<td align=\"center\"><font color=$textcolor>$serv4desc</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}
if($serv5desc != ""){
	echo "<td align=\"center\"><font color=$textcolor>$serv5desc</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}
if($serv6desc != ""){
	echo "<td align=\"center\"><font color=$textcolor>$serv6desc</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}
if($serv7desc != ""){
	echo "<td align=\"center\"><font color=$textcolor>$serv7desc</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}
if($serv8desc != ""){
	echo "<td align=\"center\"><font color=$textcolor>$serv8desc</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}
if($serv9desc != ""){
	echo "<td align=\"center\"><font color=$textcolor>$serv9desc</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}
if($serv10desc != ""){
	echo "<td align=\"center\"><font color=$textcolor>$serv10desc</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}
if($note != ""){
	echo "<td align=\"center\"><font color=$textcolor>$note</font></td>";
}else{
    echo "<td align=\"center\"><font color=#ff0000>empty</font></td>";
}    	

	echo "<td align=\"center\">[ <a href=edit_invoice.php?id=$invoiceid>edit</a> ]</td>
	<td align=\"center\">[ <a href=admin_invoice.php?id=$invoiceid >view</a> ]</td></tr>"; 
} 
echo "</table>"; 

//This counts the number or results - and if there wasn't any it gives them a little message explaining that 
$anymatches=mysql_num_rows($result); 
if ($anymatches == 0) 
{ 
echo "Sorry, but we can not find an entry to match your query<br><br>"; 
} 

//And we remind them what they searched for 
echo "<b>Your Search was for:</b> " .$find; 
echo "<br><br>";
include('footer.php');
} 
?>

Return current item: PHP Online Invoice System