473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 2742
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},10";

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>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/...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********@gmail.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********@gmail.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********@gmail.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,$find) = 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,$tuple)=($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
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...
8
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...
2
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...
11
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...
3
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...
2
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...
4
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...
4
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.