473,549 Members | 2,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Query and Display Problem

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".

2. What if I have to add another field to the display, department
budget, from table:

ACCOUNTS: DEPTNM, BUDGET

3. Display the results 10 at a time.

4. Position the results on the page using CSS.

Thanks,

Peter

Dec 31 '06 #1
5 2749
PHPBABY3 wrote:
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".
$query="SELECT * FROM EMP WHERE (LAST_NAME LIKE '%{$FIND}%') OR (FIRST_NAME
LIKE '%{$FIND}%')";

To convert the DEPTNM to NAME from the DEPT table, see
http://dev.mysql.com/doc/refman/5.0/en/join.html

2. What if I have to add another field to the display, department
budget, from table:

ACCOUNTS: DEPTNM, BUDGET
See: http://dev.mysql.com/doc/refman/5.0/en/join.html

3. Display the results 10 at a time.
Add to the query, where $startpoint= the rownumber you want to start at, minus
one (row 1 = 0, row 10 = 9, row 11 = 10).

$query.=" LIMIT {$startpoint},1 0";

4. Position the results on the page using CSS.
Go and ask a HTML newsgroup.
--

//Aho
Dec 31 '06 #2
Ric
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>Ne xt 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/...imization.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
Dec 31 '06 #3
"PHPBABY3" <sh********@gma il.comwrote:
>
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".

2. What if I have to add another field to the display, department
budget, from table:

ACCOUNTS: DEPTNM, BUDGET

3. Display the results 10 at a time.

4. Position the results on the page using CSS.
It is *NOT* the job of the folks on this newsgroup to do your homework for
you, and those who replied should be ashamed at being suckered into doing
so.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jan 1 '07 #4
Ric
Tim Roberts schrieb:
"PHPBABY3" <sh********@gma il.comwrote:
>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".

2. What if I have to add another field to the display, department
budget, from table:

ACCOUNTS: DEPTNM, BUDGET

3. Display the results 10 at a time.

4. Position the results on the page using CSS.

It is *NOT* the job of the folks on this newsgroup to do your homework for
you, and those who replied should be ashamed at being suckered into doing
so.
Instead of posting useless comments to this ng you should invest your
time in a redesign of your corporate (probo) pages, next time try to
'not' copy a popular design.
Also mind your meta section "keywords", did you know that it's
forbidden to use trademarks from other companies as keywords in your
meta section?

By the way for statics, you don't need php :-)
Jan 1 '07 #5
Tim Roberts wrote:
"PHPBABY3" <sh********@gma il.comwrote:

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".

2. What if I have to add another field to the display, department
budget, from table:

ACCOUNTS: DEPTNM, BUDGET

3. Display the results 10 at a time.

4. Position the results on the page using CSS.

It is *NOT* the job of the folks on this newsgroup to do your homework for
you, and those who replied should be ashamed at being suckered into doing
so.
J.O.Aho and Ric and all the other nice people: please don't be bothered
by someone who is mean and nasty. We can just look in the other
direction.

Now, I've worked on my problem and have broken it down into 4
subroutines, that are used like this:

1. Create a button that will appear on all pages in the application at
a particular location using CSS, and that does as follows.

2. Read 2 fields CHOICE and FIND.
a. The top one, CHOICE, is a drop-down list with the same 16 choices
each time.
Function ddlits() returns the list of 16 literal values that are
displayed.
b. The bottom one FIND is a text field with no default, so it is
blank initially.

3. By special rules used only here, we translate (2) into a list of
(Query#,SQL Query) pairs.
Function qrz($choice,$fi nd) = list of ($qnm,$sqry) pairs of Query# and
Query.

4. Execute (3) and accumulate the results into []=(Query#,Tuple) . That
is, we have a function runsql($sqry) = list of tuples returned by query
$sqry.

5. Translate (Query#,Tuple) =(Display,URL) by function
qtdis($qnm,$tup le)=($display,$ url) to create a list of links to
display.

6. Display the (Display,URL) pairs as links.

Can someone tell me how to implement this in CakePHP? Please be
explicit: I have to write what and store it where and do what to get
the button to appear on the existing pages?

Thanks,

Peter
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jan 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2324
by: James Perry | last post by:
Hi, I have been trying to build an custom report interface for a charity manangement system; which is part of my dissertation. This interface will allow the chairty to input a SQL query and submit the query. When the submit button is executed, it will display the selected column names and the query data. I am 80% finished but I have...
8
2059
by: Dave | last post by:
Hi all, I've been trying to figure this out for the last day and a half and it has me stumped. I've got a web application that I wrote that keeps track of trading cards I own, and I'm moving it from an Access 2000 database to a SQL Server 2000 database. Everything worked perfectly in Access, but I'm having trouble getting data to display...
2
1322
by: Richard New to Access | last post by:
For the Past few days I have been trying to create Query, and everyone I have asked have been obtuse with the help. I am a new to access and still learning, so it is probably that stops me from understanding. What I want - I have a query that is designed to display task deadlines to the user. It should display all the deadlines that are...
11
3132
by: Andy_Khosravi | last post by:
My problem: I'm having trouble with a query taking much too long to run; a query without any criteria evaluating only 650 records takes over 300 seconds to run (over the network. On local drive takes 120 seconds). The Setup: I'm running Access 97 non-developer edition. I have exactly zero other tools to use and no way to change that =(. ...
3
1270
by: Gil D. | last post by:
Hello, I have a query with 2 sub queries. Each query returns one value. My query should sum these values and display the sum. For example: sub query 1 returns 5 sub query 2 returns 10 my query should display 15
2
2459
by: markcarroll | last post by:
I have a rather complicating query (the SQL is about a page long) so I hope I can solve this without needing to get into specifics. Basically, the database I am working on has information about investment firms, and what companies they hold shares of. I set up the query to find all the stocks that a specified company held for the most recent...
4
13687
by: Yitzak | last post by:
Have a query that is arregated into crosstab query, it is working correctly. select Yes as selected from tblname or select true as selected from tblname Produces -1 ( vba value of True) in the results pane I would like to see it produce a checkbox with tick in just like I would see if I displayed a boolean/yes/no field from a table.
4
4565
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The...
3
3793
by: Coll | last post by:
I have a form that had been setup with a combo box. You'd select a value from the combo box and a query would open and display matching records. I now need to remove the combo box and set up a text box so the user types in a value and the query opens displaying any records that contain that value in the field. For example, the user enters...
0
7526
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7723
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7965
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7483
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7817
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5092
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
771
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.