Location: PHPKode > projects > Computer Service Company Database > SOLOCMS/dogbert/searchinvoices.php
<?
include("db.php"); 

if (empty($_POST)) {   ?>
<form method="post">
  <div align="center">
  <select name="searchchoose" size="1">
    <option value="lastname">Last Name</option>
    <option value="date">Date</option>
    <option value="id">Invoice Id</option>
  </select>
  <input type="text" name="search" size="25">
  <input type="submit" value="Search For Invoice">
  </div>
</form>
<? }
if (!empty($_POST)) { 
  // setup connection to mysql ?>
<form method="post">
  <div align="center">
  <select name="searchchoose" size="1">
    <option value="lastname">Last Name</option>
    <option value="date">Date</option>
    <option value="id">Invoice Id</option>
  </select>
  <input type="text" name="search" size="25">
  <input type="submit" value="Search For Invoice">
  </div>
</form>
<?


if ($searchchoose == 'lastname') {
$query = mysql_query("SELECT invoice.date, invoice.clientid, invoice.id, invoice.total, invoice.paid FROM invoice INNER JOIN results ON invoice.clientid=results.id WHERE results.lastname = '".$search."'");
}
else{
$query = mysql_query("SELECT * FROM invoice WHERE $searchchoose LIKE '%$search%' LIMIT 0, 30 ");
}

?>
<table >

<? echo "

        <p class=\"invoice\" align=\"center\"><b>Current Invoices With <font color=\"red\">$searchchoose</font> Like <font color =\"red\">$search</font></b></p>
        <table align=\"center\" border=\"1\" cellpadding=\"2\" cellspacing=\"7\">
                         <tr>
						 <td  class=\"invoice\" align=\"left\"><b>Name</b></td>
						 <td  class=\"invoice\" align=\"left\"><b>Invoice ID</b></td>
            <td  class=\"invoice\" align=\"left\"><b>Date</b></td>
            <td  class=\"invoice\" align=\"left\"><b>Total</b></td>
            <td  class=\"invoice\" align=\"left\"><b>Print</b></td>
            <td  class=\"invoice\" align=\"left\"><b>Edit</b></td>
            <td  class=\"invoice\" align=\"left\"><b>Mark Paid</b></td>
	     	
</tr>"; 
while ($row  =  mysql_fetch_array($query))
   {
			
	$result4 = mysql_query("SELECT * FROM results WHERE id = $row[clientid]");

   $row4 = mysql_fetch_assoc($result4);
    
			if ($row[paid] == "0")
{

            echo "

			<tr> 
            <td  class=\"invoice\" bgcolor=\"#F2B7A6\">{$row['clientid']} - {$row4['firstname']} {$row4['lastname']}</td>
            <td  class=\"invoice\" bgcolor=\"#F2B7A6\">{$row['id']}</td> "; ?>
			<td  class="invoice" bgcolor="#F2B7A6"><?php echo date('l, jS F Y',strtotime($row['date'])); ?></td>
			<? echo 
			
			"
			<td  class=\"invoice\" bgcolor=\"#F2B7A6\">{$row['total']}</td>
			<td  class=\"invoice\" bgcolor=\"#F2B7A6\"><form action=\"printinvoice.php\" method=\"POST\" target=\"_blank\">
            <input type=\"hidden\" name=\"invoice\" value =\"{$row['id']}\">
            <input type=\"submit\" name=\"submit\" value=\"Print Invoice\">
            </form>
			</td>
            <td  class=\"invoice\" bgcolor=\"#F2B7A6\"><a href=\"invoice.php?edit={$row[id]}\" target=\"_parent\"> Edit Invoice </a></td>
            <td  class=\"invoice\" bgcolor=\"#F2B7A6\"><a href=\"invoice.php?markpaid={$row[id]}\" target=\"_parent\"> Mark Paid </a></td>

            </tr> 

";


 }// dont delete
else {echo "

			<tr> 
            <td class=\"invoice\" >{$row['clientid']} - {$row4['firstname']} {$row4['lastname']}</td>
            <td class=\"invoice\" >{$row['id']}</td> "; ?>
			<td class="invoice" ><?php echo date('l, jS F Y',strtotime($row['date'])); ?></td>
			<? echo 
			
			"<td class=\"invoice\" >{$row['total']}</td>
			<td class=\"invoice\" ><form action=\"printinvoice.php\" method=\"POST\" target=\"_blank\">
            <input type=\"hidden\" name=\"invoice\" value =\"{$row['id']}\">
            <input type=\"submit\" name=\"submit\" value=\"Print Invoice\">
            </form>
			</td>
            <td class=\"invoice\" ><a href=\"invoice.php?edit={$row[id]}\" target=\"_parent\"> Edit Invoice </a></td>
            <td class=\"invoice\" >&nbsp;</td>

            </tr> ";

       } } 



        echo "</table>"; 

    } 

 

?>
Return current item: Computer Service Company Database