Jump to content

cheryl

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cheryl's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=363404:date=Apr 10 2006, 02:15 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 10 2006, 02:15 PM) [snapback]363404[/snapback][/div][div class=\'quotemain\'][!--quotec--] I suggest you add some error trapping code [code]$search_participant = "SELECT * FROM " .$clientCode. "m WHERE memName                               LIKE '%$namesearch%' ORDER BY memCode"; $result = mysql_query($search_participant) or die (mysql_error() . ' <br>' . $search_participant );[/code] and what error do you get. [/quote] the error is Couldn't execute query.
  2. the query still won't execute. by the way, the m isn't a typo. the $clientCode is suppose to join to the m to get $clientCodem table. [!--quoteo(post=363250:date=Apr 10 2006, 05:31 AM:name=willpower)--][div class=\'quotetop\']QUOTE(willpower @ Apr 10 2006, 05:31 AM) [snapback]363250[/snapback][/div][div class=\'quotemain\'][!--quotec--] I think its because you have double quotes around $clientCode. try changing it to $search_participant = "SELECT * FROM ' .$clientCode. 'm WHERE memName LIKE '%$namesearch%' ORDER BY memCode"; ...and whats the m for...is this just a typo? and add single quotes around memName 'memName' Try that and see [/quote]
  3. [code] $search_participant = "SELECT * FROM " .$clientCode. "m WHERE memName                               LIKE '%$namesearch%' ORDER BY memCode"; [/code] is this query won't execute. is there a problem with joining the .$clientCode. to the m?
  4. i keep getting a parse error at line 44. it said something like " parse error '[' .... at line 44." but at line 44 there isn't any [].
  5. 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.
  6. thank you very much. i think i understand it better with explanation.
  7. hi. could you like explain line by line what the code does? and what are the variables for? i'm a little bit confuse. oh! i do have a textfield and button to submit the search though. thank you
  8. i have clients' members tables which are created "dynamically". for example, i have client ABC and their members table would be ABCm, client XYZ will have XYZm and will go the same for all the other clients members' table. by the way, the fields in all of these tables are the same. i would like to know how is it possible to do a select statement where i can combine all the clients' members tables to do a search? cuz i do not want/have to add table name if there is a new client. how how?? can anybody assist?
  9. cheryl

    wild search

    anyone can help guide or teach on how to do a wild search select statement?? [code]         $member2    = "SELECT m.memCode,m.memName,c.clientName         FROM member m,client c         WHERE m.memCode LIKE %_%         ORDER BY memCode ASC";         $member_result2 = mysql_query($member2)         or die("Couldn't execute query 2.");     [/code] is the following correct?? can also follow up on to print the number of records found and print them in table. help please.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.