Forums

This topic is locked

1 to many relationship

Posted 30 Jul 2002 12:11:52
1
has voted
30 Jul 2002 12:11:52 Man CHAN posted:
Hi there,

How can I set the relationship to 2 table. Because 1 member can own lots of
product. mySQL please. Thanks

Table 1 (member) field:
m_id (auto_increment, PK)
user_id (text)
name (text)
phone (text)
password (text)

Table 2 (product) field:
p_id (auto_increment, PK)
m_id (relate to member table)
user_id (relate to member table)
product_name (text)
serial (text)

Replies

Replied 01 Aug 2002 13:29:29
01 Aug 2002 13:29:29 Julio Taylor replied:
To select all the products belonging to a single member, coming from another page which passes on the m_id variable as the common field between the 2 tables:

<pre id=code><font face=courier size=2 id=code>
select * from table2 where m_id = MMColParam
</font id=code></pre id=code>

then you can specify the variable m_id as an HTTP_GET variable:

<pre id=code><font face=courier size=2 id=code>

Name Def Value Runtime Value
---------------------------------------------------------------------------------
MMColParam 0 $HTTP_GET_VARS["m_id"]

</font id=code></pre id=code>

just make sure you use a "Go to Detail page" link on the previous page to ensure the variable is correctly passed on....

I hope it helps.

------------------------
Poolio

MSN:

www.eliziumdesign.com

Reply to this topic