cheryl
02-14-2006, 05:35 AM
is there anywhere i can get a free search script download??
|
||||
Free search script downloadcheryl 02-14-2006, 05:35 AM is there anywhere i can get a free search script download?? fci 02-14-2006, 05:44 AM could you be more clear about what you are asking. what do you want it to search? have you tried looking here? http://www.hotscripts.com/PHP/Scripts_and_Programs/index.html you are too vague for me to be of any real help to you(yet). cheryl 02-14-2006, 05:59 AM could you be more clear about what you are asking. what do you want it to search? have you tried looking here? http://www.hotscripts.com/PHP/Scripts_and_Programs/index.html you are too vague for me to be of any real help to you(yet). search data from 4 tables in a database. like table 1, table 2 and table 3 have a common field with table4. select some info from tables 1,2, and 3 that has a common field linked to table4 fci 02-14-2006, 06:35 AM unlikely you'd find what you were looking for on the web, i'd suggest writing it yourself or post the create syntax for the tables so we can post queries you could use (at least that's how much I'd be willing to help). cheryl 02-14-2006, 06:53 AM unlikely you'd find what you were looking for on the web, i'd suggest writing it yourself or post the create syntax for the tables so we can see post queries you could use (at least that's how much I'd be willing to help). <?php if (isset($_POST['submit'])) { search_query(); }else{ search_form(); } function search_form() { ?> <html> <style type="text/css"> <!-- .style1 { color: #FF6600; font-weight: bold; font-family: Verdana; } .style4 {font-family: Arial, Helvetica, sans-serif} --> </style> <bodY> <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>"> <table width="430" border="0" cellpadding="0"> <tr> <td width="350"><span class="style1"><u>Search</u></span></td> <td width="74"> </td> </tr> <tr> <td><span class="style4">Member Code: <input type="text" name="Code"> <br> </span></td> </tr> <tr> <td><span class="style4">Member Name: <input type="text" name="Name"> </span></td> </tr> <tr> <td><span class="style4">Organisation Name: <input type="text" name="orgName"> </span></td> </tr> <tr><td colspan='2' align='center'><input type="SUBMIT" name='submit' value="Search"></td> </tr> </table> </form> </bodY> </html> <?php }//end function function search_query() { // PHP Search Script include("db.php"); // connect to db $db = mysql_connect($dbhost, $dbusername, $dbpassword); mysql_select_db($dbname,$db); //initialize vars $Code = ''; $Name = ''; $orgName = ''; if (!empty($_POST['Code'])) {$Code =$_POST['Code']; } if (!empty($_POST['Name'])) {$Name =$_POST['Name']; } if (!empty($_POST['orgName'])) {$orgName =$_POST['orgName']; } if(($Code != '') || ($Name != '') || ($orgName != '')) { //build the query with the requested info $search_query1 = "select m.memCode, m.memName, c.clientName from member as m left outer join client as c on m.clientCode = c.clientCode"; $search_query2 = "select n.nmCode, n.nmName, c.clientName from nonmember as n left outer join client as c on n.clientCode = c.clientCode"; $search_query3 = "select ni.nimCode, ni.nimName, c.clientName from nimember as ni left outer join client as c on ni.clientCode = c.clientCode"; if($Code != ''){ $search_query1 .= " and m.memCode like '%$Code%' "; $search_query2 .= " and n.nmCode like '%$Code%' "; $search_query3 .= " and ni.nimCode like '%$Code%' "; } if($Name != ''){ $search_query1 .= " and m.memName like '%$Name%' "; $search_query2 .= " and n.nmName like '%$Name%' "; $search_query3 .= " and ni.nimName like '%$Name%' "; } if($orgName != ''){ $search_query1 .= " and c.clientName like '%$orgName%' "; $search_query2 .= " and c.clientName like '%$orgName%' "; $search_query3 .= " and c.clientName like '%$orgName%' "; } $search_query = '(' . $search_query1 . ') UNION ('. $search_query2 . ') UNION (' . $search_query3 . ')'; //run the query $search = mysql_query($search_query,$db) or die (mysql_error()); if (mysql_num_rows($search)>0) { while(list ($CodeResult, $NameResult, $orgNameResult)=mysql_fetch_array($search)) { echo "<font color= #ff6600><u><b>Search Results</b></u>"; echo "<table width=500 border=1 cellpadding=0>"; echo "</tr bgcolor=#ff9900>"; echo "</tr>"; echo "<td bgcolor = #ff9900><b>Member Code</b>"; echo "<td bgcolor = #ff9900><b>Name</b>"; echo "<td bgcolor = #ff9900><b>Organisation</b>"; echo "</tr>"; echo "<td> $CodeResult"; echo "<td> $NameResult"; echo "<td> $orgNameResult"; echo "</table>"; echo "<br><br>"; } } else { //no results from search echo "<font color=red>*No results found matching your criteria of [ member code = $Code"; if (!empty($Code)) { echo ",member code = $Code ";} if (!empty($Name)) { echo ", member name = $Name "; } if (!empty($orgName)) { echo ", org name = $orgName"; } echo "]</font>"; } }else{ //call the search form again and pop up an alert box to tell the user to choose an option search_form(); die("<script language='javascript'>alert('Enter Member Code at the very least!');</script>"); } }//end function ?> this code here is works. but just that, it wont select the data if i type in for danny for example. it will populate data from all 3 tables. how can it be changed so that when i type danny, all dannys will be selected from the tables? please kindly assist. i need it urgently... |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum