Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Displaying Related Data From Another Table

Quote Reply
Displaying Related Data From Another Table
I am using dbmansql to provide a search facility on a craft website. The search displays thumbnails and names of products. When a thumbnail is clicked, dbmansql displays further product information and a large image. I want to extend the further information displayed by pulling in information from other tables. For example, I want to list related products: -

Tables

Products: Prod_Code(PK), Prod_Name, Desc, List_Price, Our_Price

Related_Products: Rel_Prod_Code(FK), Rel_Code, Rel_Desc

(A one to many relationship between Products and Related_Products)

I have modified the homes templates which came with the installation. Specifically the search_results.html and record_form.html templates. search_results calls record_form as follows: -

<%loop results%>
<p><%include record_form.html%>
<%endloop%>

and record_form simply formats and displays each product attribute. How can I lookup the multiple rows of related information from the Related_Products table?

In record_form I would like to do the following: -

Select * from Related_Products where Rel_Prod_Code = <%Prod_Code%>

Loop for each result

Display Rel_Code and Rel_Name

End Loop

I am sorry that this may appear a very basic problem but I have spent hours trying to understand the relationship between globals, templates, functions etc and I would just like someone to point me in the right direction.

Thanks!

Last edited by:

danah: Dec 30, 2003, 8:03 AM
Subject Author Views Date
Thread Displaying Related Data From Another Table danah 2981 Dec 30, 2003, 7:59 AM
Thread Re: [danah] Displaying Related Data From Another Table
604 2917 Dec 30, 2003, 12:37 PM
Thread Re: [TheStone] Displaying Related Data From Another Table
danah 2895 Jan 2, 2004, 8:47 AM
Post Re: [danah] Displaying Related Data From Another Table
604 2889 Jan 2, 2004, 10:04 AM