|  | Posted by Ric on 12/31/06 11:12 
PHPBABY3 schrieb:> Hi,
 >
 > 1. I have two SQL tables.  I will call them employees and departments:
 >
 > EMP: LAST_NAME, FIRST_NAME, DEPTNM
 > DEPT: NUM, NAME
 >
 > Input: text string FIND
 >
 > Output: the LAST_NAME, FIRST_NAME and department name NAME (link DEPTNM
 > in EMP to NUM in DEPT) of all employees whose LAST_NAME or whose
 > FIRST_NAME contains the string FIND in a case-insensitive manner.
 > Example: Employees with LAST_NAME = "Sandleburg" are listed when
 > input FIND = "BURG".
 
 
 $sql = "SELECT A.LAST_NAME A.FIRST_NAME B.NAME FROM EMP A left join DEPT
 B on A.DEPTNM = B.NUM WHERE A.LAST_NAME LIKE '%$FIND%';";
 
 
 
 
 
 
 >
 > 2. What if I have to add another field to the display, department
 > budget, from table:
 >
 > ACCOUNTS: DEPTNM, BUDGET
 
 add another left join as shown above
 
 >
 > 3. Display the results 10 at a time.
 
 Add links to your page that contain the some sort of count, like:
 
 <a href="yourpage.php?count=11>Next 10</a>
 
 and use LIMIT to only display from 11 to 20 if someone cicks next etc.:
 http://dev.mysql.com/doc/refman/5.0/en/limit-optimization.html
 
 >
 > 4. Position the results on the page using CSS.
 
 just add a class="cssname" to your div etc.
 
 <div class="myoutput">
 Whatever you want to display here a table , option list etc.
 </div>
 
 css:
 
 #myoutput {
 RIGHT: 10%; LEFT: 10%; WIDTH: 80%; POSITION: absolute; TOP: 100px;
 }
 
 >
 > Thanks,
 >
 > Peter
 >
  Navigation: [Reply to this message] |