Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QUERY from 2 TABLES Problem!

Status
Not open for further replies.

gplemos

MIS
Mar 13, 2000
15
US
I am working on an update form that queries data from a database by the unique identifier. But I am also including another query to a table that lists information on a bunch products we'll call them.

The first query gets the data that matches the unique identifier, the second query hits the second table listing all the products on the update form. On the update form there are CHECKBOXES next to a list of products that are displayed from the second tables query. And if a match is made in the first table (Persons personal info) it will display a checkbox checked next to the product.

I used to have this update form working fine, but it listed ALL products in static fashion. If I ever wanted to make an update to all the products I would have to do so manually in each page they are listed hence why I made a table that has them all for easy maintenance.

Anyway..

My problem is NOW ALL THE DATA is being cycled on the page over and over..

(IE: Lists a HTML TABLE with the update form with name, address, etc etc, then another table with name, address, etc etc etc., then again, and again..)

HOW DO I GET IT TO JUST SHOW THE DATA IN ONE UPDATE FORM WITH OUT IT LOOPING OVER AND OVER?!

I have included the QUERY CODE in the box below. "People" is the table with the users personal info and associated product. "SIMS" is the table with all the products.

Thanks for your help!

(CFQUERY name="people" datasource="STRS")
Select people.*, SIMS.sim2, SIMS.company
from people, sims
WHERE people.PID = #URL.pid#
(/CFQUERY)

 
try changing your query to
Select PEOPLE.PID AS PRODID, people.*, SIMS.sim2, SIMS.company
from people, sims
WHERE people.PID = #URL.pid#


Now use CFOUTPUT to display your Products which you get from the other query(which has a name "products")

Wherever you try to display your Check box try this code

<cfif #people.prodid# Is #products.pid#>
<cfinput type=&quot;checkbox&quot; name=chk#pid# checked>
<cfelse>
<cfinput type=&quot;checkbox&quot; name=chk#pid# >
</cfif>

hope this works for you

Perichazhi

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top