Forum Moderators: coopster

Message Too Old, No Replies

mySQL Tables linking etc.

         

mark40

8:20 pm on Jul 11, 2008 (gmt 0)

10+ Year Member



Hi All and thanks for having me :-)

I have a small problem that I can't seem to get my head around.
I have a directory site that allows searching of a table (customers).
The results page shows each customer that corresponds to the search query in a repeat region that is linked to their detail page. Below each entry I have the categories that they are in.
I would like to have these categories linked to their appropriate static pages but I'm not sure how to go about this.
I have 2 tables in 1 database: 'customers' and 'categories'
Table 'customers' has all contact info and up to 6 categories(in separate cols) that each customer is in.
Table 'categories' has 3 rows "id, cat, url". I want to dynamically link the echo'd categories on the result page with the correct url without having to restructure the 'customer' table or add info manually, but I can't figure out how to 'wrap' the echo'd category text with the correct echo'd url. i.e. associating category pulled from 1 table with category & url pulled from another according to customer ref# I have set up.

I hope I've been clear. It's not complicated to show, but it is to explain.

Here are 2 links to images of how the tables are setup.

<snip>

Any help would be great at this point. I'm tearing my hair out!

[edited by: eelixduppy at 8:21 pm (utc) on July 11, 2008]
[edit reason] removed URLs [/edit]

henry0

9:42 pm on Jul 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mark40 Welcome to WebmasterWorld!
You need to have a field that could be similar in both tables
Or you need to extract first some data from each table that could be used as a defining parameter to query both tables in one shot
Then it looks like you need to use a simple join
Something like:
SELECT u.f_name, u.l_name, u.email, u.type, m.subject, m.htmlbody, m.textbody
FROM users u, mail_content m
WHERE (
u.f_name = 'aaaa'
)
AND (
m.subject = 'bbbb'