arcticvman
MIS
I am trying to have this search return information from one of the two queries.
So, if the first query does not return any results then it would run the second query and show those results.
And, if no results were found from either query, it would just say nothing found.
The records that I am searching for are in history or active tables, so, if it does not find it in the active table it searches the history table.
I am using SQL2008r2 and PHP 5.4.3
Thanks in advance.
Mario
Below is my current search:
So, if the first query does not return any results then it would run the second query and show those results.
And, if no results were found from either query, it would just say nothing found.
The records that I am searching for are in history or active tables, so, if it does not find it in the active table it searches the history table.
I am using SQL2008r2 and PHP 5.4.3
Thanks in advance.
Mario
Below is my current search:
Code:
<?php
$conn = odbc_connect('db','user','pw') or die ('DB Connection Failed.');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Search</title>
</head>
<body>
<form method="GET" action="search.php" id="frm" name="frm" >
<table width="500" border="0">
<tr>
<td>Search</td>
<td>
<input type="text" name="fullname" id="fullname"/> </td>
</tr>
<tr>
<td>
<input type="submit" name="Submit" value="Search"/> </td>
<td> </td>
</tr>
</table>
</form>
<?php
if(!isset($_GET['fullname'])) die("Search query not found");
$var = $_GET['fullname'];
if($_REQUEST["Submit"]=="Search")
if($conn)
{
$QUERYA = "SELECT
db.ship_via_cd AS shipper,
db.oe_po_no AS custpo,
convert(varchar,db.shipping_dt,107) AS Ship_Dt,
db.cmt_1 AS PRO_No,
db.phone_number AS phone3,
//...snip
convert(varchar,db.inv_dt,107) AS invdate
FROM db JOIN dblin ON db.ord_no = dblin.ord_no
JOIN item ON item.item_no = dblin.item_no
WHERE (oe_po_no like '%$var%' OR db.user_def_fld_3 LIKE '%$var%' OR db.cmt_1 LIKE '%$var%' OR db.ship_to_name LIKE '%$var%')
";
$result = odbc_exec($conn,$QUERYA);
{
$QUERYB = "SELECT
history.ship_via_cd AS shipperb,
history.oe_po_no AS custpob,
convert(varchar,history.shipping_dt,107) AS Ship_Dtb,
history.cmt_1 AS PRO_Nob,
history.phone_number AS phone3b,
//...snip
convert(varchar,history.inv_dt,107) AS invdateb
FROM history JOIN history2 ON history.ord_no = history2.ord_no
JOIN item ON item.item_no = history2.item_no
WHERE (oe_po_no like '%$var%' OR history.user_def_fld_3 LIKE '%$var%' OR history.cmt_1 LIKE '%$var%' OR history.ship_to_name LIKE '%$var%')
";
$result1 = odbc_exec($conn,$QUERYB);
?>
<table width="500" border="1">
<caption><B>Ship Info</B></caption>
<tr>
<th>shipper</th>
<th>item</th>
<th>description</th>
<th>qtyord</th>
<th>DSPO</th>
<th>customer</th>
<th>PRO_No</th>
<th>custpo</th>
<th>shipname</th>
<th>Ship_Dt</th>
<th>shipcity</th>
<th>shipstate</th>
<th>shipzip</th>
<th>phone</th>
<th>invoice</th>
<th>invdate</th>
<?php
while($row = odbc_fetch_array($result)){
?>
<tr>
<td><?php echo $row['shipper']; ?></td>
<td><?php echo $row['item']; ?></td>
<td><?php echo $row['description']; ?></td>
<td><?php echo $row['qtyord'];?></td>
<td><?php echo $row['DSPO']; ?></td>
<td><?php echo $row['customer'];?></td>
<td><?php echo $row['PRO_No'];?></td>
<td><?php echo $row['custpo'];?></td>
<td><?php echo $row['shipname'];?></td>
<td><?php echo $row['Ship_Dt'];?></td>
<td><?php echo $row['shipcity'];?></td>
<td><?php echo $row['shipstate'];?></td>
<td><?php echo $row['shipzip'];?></td>
<td><?php echo $row['phone3'];?></td>
<td><?php echo $row['invoice'];?></td>
<td><?php echo $row['invdate'];?></td>
</tr>
<?PHP
}
}
}
?>
</table>
</body>
</html>