Current location: Hot Scripts Forums » General Community » Script Requests » Good search script?


Good search script?

Reply
  #1 (permalink)  
Old 01-19-10, 03:26 PM
CountryGirlDesigns CountryGirlDesigns is offline
Newbie Coder
 
Join Date: Jan 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Good search script?

I have a search script, but I'm not sure if it's working too well, so I thought I'd also see if there is a better search script out there if I can't figure out the problem with my current script.

I need a search code that I can join in multiple tables from my database, and the results will return in a table type of structure. It's gotta be a pretty simple code .

Thanks!
Qadoshyah
Reply With Quote
  #2 (permalink)  
Old 01-19-10, 08:52 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Please post your code and any notes on how you'd like to improve it.
Reply With Quote
  #3 (permalink)  
Old 01-19-10, 10:12 PM
CountryGirlDesigns CountryGirlDesigns is offline
Newbie Coder
 
Join Date: Jan 2010
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by wirehopper View Post
Please post your code and any notes on how you'd like to improve it.
The code I have right now is:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<?php
   $dbHost = '********'; 
   $dbUser = '**********'; 
   $dbPass = '*********';
   $dbDatabase = '***********'; 
  

$search = $_POST['search'];

if ($search) // perform search only if a string was entered.
{
   $con = mysql_connect($dbHost, $dbUser, $dbPass) or die("Failed to connect to MySQL Server. Error: " . mysql_error());
   mysql_select_db($dbDatabase) or die("Failed to connect to database {$dbDatabase}. Error: " . mysql_error());
   
   
   $query = "SELECT asmnt_legal.Account, asmnt_legal.Legal, cmn_name.OwnersName, cmn_name.Address1, cmn_name.Address2, cmn_name.City, cmn_name.State, cmn_name.ZipCode, asmnt_parcel.ParcelID, asmnt_parcel.LotSize, asmnt_parcel.LotSizeType, asmnt_parcel.Township, asmnt_parcel.Range, asmnt_parcel.Section, asmnt_parcel.Quarter, asmnt_situs.Situs, appr_agland.Acres,
             LEFT JOIN cmn_name ON asmnt_legal.KeyID=cmn_name.KeyID
             LEFT JOIN asmnt_parcel ON asmnt_legal.Account=asmnt_parcel.KeyID
             LEFT JOIN asmnt_situs ON asmnt_legal.Account=asmnt_situs.KeyID
             LEFT JOIN appr_agland ON asmnt_legal.Account=appr_agland.KeyID
             WHERE asmnt_legal.Account = '{$search}' OR cmn_name.OwnersName = '{$search}' OR cmn_name.Address2 = '{$search}' OR asmnt_parcel.ParcelID = '{$search}' OR asmnt_situs.Situs = '{$search}' OR asmnt_parcel.Township = '{$search}' OR asmnt_parcel.Range = '{$search}' OR asmnt_parcel.Section = '{$search}' OR asmnt_parcel.Quarter = '{$search}'
             ORDER BY asmnt_legal.Account ASC, asmnt_legal.Legal ASC";
   $result = mysql_query($query, $con);

   if ($result)
   {
      echo "Results:<br><br>";
      echo "<table width=90% align=center border=1><tr>
      <td align=center bgcolor=#4A6B3F>Account</td>
      <td align=center bgcolor=#4A6B3F>Owners Name</td>
      <td align=center bgcolor=#4A6B3F>Address 1</td>
      <td align=center bgcolor=#4A6B3F>Address 2</td>
      <td align=center bgcolor=#4A6B3F>City</td>
      <td align=center bgcolor=#4A6B3F>State</td>
      <td align=center bgcolor=#4A6B3F>Zip Code</td>
      <td align=center bgcolor=#4A6B3F>Parcel</td>
      <td align=center bgcolor=#4A6B3F>Legal</td>
      <td align=center bgcolor=#4A6B3F>Situs</td>
      <td align=center bgcolor=#4A6B3F>Size</td>
      <td align=center bgcolor=#4A6B3F>Type</td>
      <td align=center bgcolor=#4A6B3F>Township</td>
      <td align=center bgcolor=#4A6B3F>Range</td>
      <td align=center bgcolor=#4A6B3F>Section</td>
      <td align=center bgcolor=#4A6B3F>Quarter</td>
      </tr>";
   
      while ($r = mysql_fetch_array($result))
      { // Begin while
         $act = $r["Account"];
         $name = $r["OwnersName"];
         $add1 = $r["Address1"];
         $add2 = $r["Address2"];
         $city = $r["City"];
         $state = $r["State"];
         $zip = $r["ZipCode"];
         $parcel = $r["ParcelID"];
         $legal = $r["Legal"];
         $situs = $r["Situs"];
         $lot1 = $r["LotSize"];
         $acres = $r["Acres"];
         $twn = $r["Township"];
         $range = $r["Range"];
         $sec = $r["Section"];
         $quart = $r["Quarter"];
         echo "<tr>
            <td>$act</td>
            <td>$name</td>
            <td>$add1</td>
            <td>$add2</td>
            <td>$city</td>
            <td>$state</td>
            <td>$zip</td>
            <td>$parcel</td>
            <td>$legal</td>
            <td>$situs</td>
            <td>$lot1</td>
            <td>$acres</td>
            <td>$twn</td>
            <td>$range</td>
            <td>$sec</td>
            <td>$quart</td>
            </tr>";
      } // end while
      
      echo "</table>";
   }
   else
   {
      echo "Sorry, please try your search again.";
   }
}
else
{
   echo "Start your search";
}
?>

<html xmlns="http://www.w3.org/1999/xhtml">

<head><title>Searching Another Test</title>
</head>
<body bgcolor="#bba86d">
		<div align="center">
			
		</div>
		<h1></h1>
		<h1></h1>
		<h1>Search Records</h1>
		<form method="post" action="searchjoin.php">
<table width=90% align=center>
				<tr><td>Search:</td><td><input type=text name='search' size=60 maxlength=255></td></tr>
				<td></td>
				<td><input type=submit value="Search Records"></td>
				</tr>
			</table>
</form>
		<p></p>
		<p></p>
	</body>
</html>
I'm having some troubles with the code at the moment (not sure why, but it may be the host's end).

I want something similar to this. The results need to return in a table like setting with rows, if that makes sense. And, it needs to be easily searched. Other than that, I'm not too picky!

Thanks!

Qadoshyah
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a good review management script griz_fan Script Requests 10 07-29-07 05:08 AM
Need Advanced PHP MySql Search Script HowdeeDoodee Script Requests 0 05-08-07 12:46 AM
[Hiring] A PHP programmer can make a simple Search Script - asap zanary Job Offers & Assistance 1 04-04-07 06:48 AM
I need a Search script danlew Script Requests 0 12-26-05 03:56 AM
SEO Expert Available nakulgoyal Job Offers & Assistance 2 08-14-04 12:38 PM


All times are GMT -5. The time now is 09:59 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.