i seem to have a problem with the codes now. [code] <?php session_save_path("../servertemp"); session_start(); if(empty($_SESSION[login])) //check if the user has logged in, if not redirect the user to login page { $_SESSION[error]="Access Denied! You need to login first."; header("Location: ../login.php"); } else { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 { font-family: Verdana; font-weight: bold; font-size: 12px; } --> </style> </head> <body> <form name="form1" method="post" action="<? $PHP_SELF?>"> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="90"><span class="style1">Search:</span></td> <td width="223"><input type="text" name="name"></td> <td width="187"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> <p> <?php include("../lib/db_connect.php"); $link = @mysql_connect("localhost", $user, $pass); if (!$link) die ("Couldn't connect to MySQL"); mysql_select_db($db, $link) or die ("Couldn't open $db".mysql_error()); $keyperson = ""; if(!empty($_POST["name"])) { $mkeyperson = ["name"]; } if($keyperson!="") { $i=1; //Query to select all members from you members table, you will need to change member_name //to the field that has all your members names under it and change members to the name of your //table with all the members in $query=mysql_query("SELECT clientCode FROM client"); //While there are still users not selected keep going while ($clients=mysql_fetch_array($query)) { //If this is the first time the loop has gone through then we dont need ther 'OR' or the ',' infront if ($i=1) { $tables=($clients["clientCode"].'m'); $searchfields=($clients["clientCode"]."m.memName LIKE %$keyperson%"); $i++; }//end if //else we need to add the 'OR' and ',' else { //basically creating a line with ABCm and XYZm and making the query select all the tables $tables=($tables.', '.$clients["clientCode"].'m'); //below does similar but sets it up like this: ABCm.searchfield LIKE'$search_item... //where searchfield is you need to rename that to the field in your table that you want to rename //and where $search_item is you need to change to the variable that hold the value of your search $searchfields=($searchfields.'OR '.$clients["clientCode"]."m.memName LIKE %$keyperson%"); }//end else }//end while //below puts the whole query together so it will be along the lines of: //SELECT * FROM ABCm, BCDm, CDEm WHERE ABCm LIKE 'searched word/phrase' OR BCDm //LIKE 'searched word/phrase' OR CDEm LIKE 'searched word/phrase' $results=mysql_query("SELECT * FROM $tables WHERE $searchfields"); print "<font face=Verdana size=1>"; print "<table width=790 align=center border=1 bordercolor=orange cellspacing=0 cellpadding=5>"; print "<tr>Member Results</tr>"; print "<tr bgcolor=#ff9900>"; print "<td align=left width=100><b>Member Code</b></td>"; print "<td align=left width=100><b>NRIC</b></td>"; print "<td align=left width=300><b>Name</b></td>"; print "<td align=left width=140><b>Designation</b></td>"; print "</tr>"; while ($row=mysql_fetch_array($results)) { print "<font face=Verdana size=1>"; print "<table width=790 align=center border=1 bordercolor=orange cellspacing=0 cellpadding=5>"; print "<td align=left width=100>".$row['memCode']"</td>"; $nric = substr($row["nric"], -5); print "<td align=left width=100>Sxxx$nric</td>"; print "<td align=left width=300>".$row['memSalute']." ".$row['memName']."</td>"; print "</tr>"; } $nmquery=mysql_query("SELECT * FROM nonmembers WHERE nmName LIKE %$keyperson%"); print "<font face=Verdana size=1>"; print "<table width=790 align=center border=1 bordercolor=orange cellspacing=0 cellpadding=5>"; print "<tr>Non-member Results</tr>"; print "<tr bgcolor=#ff9900>"; print "<td align=left width=100><b>Member Code</b></td>"; print "<td align=left width=300><b>Name</b></td>"; print "<td align=left width=140><b>Designation</b></td>"; print "<td width=100 align=center><b>Organisation</b></td>"; print "</tr>"; while ($row=mysql_fetch_array($nmquery)) { print "<font face=Verdana size=1>"; print "<table width=790 align=center border=1 bordercolor=orange cellspacing=0 cellpadding=5>"; print "<td align=left width=100>".$row['nmCode']"</td>"; print "<td align=left width=300>".$row['nmSalute']." ".$row['nmName']."</td>"; print "<td align=left width=100>".$row['nmDes']"</td>"; print "<td align=left width=200>".$row['nmOrgName']"</td>"; print "</tr>"; } } ?> </body> <? } ?> </p> </form> </html> [/code] i'm getting the clientCode from the clients' table to match to .m for get all the tables with clientCode.m from there, i will get all members from all the .m tables, right?? then will print out what i've searched for. i have one other non-members table where it will output whatever i typed in to the textfield for the search, and then print the results. my fren has seen the codes and think there's no problem with it. however there is an error when i have it run. i aint sure if it's my localhost that is giving the problem, or the code itself. but just want to check that what i'm doing, is correct right?? assist please.