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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display 2 fields in one page??

Status
Not open for further replies.

hisham

IS-IT--Management
Nov 6, 2000
194
I have tow tables:
1- name, contains: NameID and contact
2- phone, contains: PhoneID and PhoneNo
How to display “contact” and “PhoneNo” in one page?

Thanks in advance.
 
$q="SELECT NameID,contact FROM name";
$res=mysql_query($q);
while($row=mysql_fetch_array($res)){
print($row[&quot;NameID&quot;].&quot;-----&quot;.$row[&quot;contact&quot;].&quot;<br>&quot;);
}

$q=&quot;SELECT PhoneID,PhoneNo FROM phone&quot;;
$res=mysql_query($q);
while($row=mysql_fetch_array($res)){
print($row[&quot;PhoneID&quot;].&quot;-----&quot;.$row[&quot;PhoneNo&quot;].&quot;<br>&quot;);
}


Rick If I have helped you just click the first link below to let me know :)
 
how do you associate phones with contacts?

I think you need a little database help before coding. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
If you have tables that have relationships, you can do something like the following:

TABLE NAME:
[tt]
NAMEID | CONTACT
1 | John Doe

TABLE PHONE:

NAMEID | PHONEID | PHONE
1 | 1 | 480-555-1212
1 | 2 | 480-555-1213
[/tt]

Then, your query would be:
SELECT NAME.CONTACT,PHONE.PHONEID,PHONE.PHONE FROM NAME,PHONE WHERE NAME.NAMEID=PHONE.NAMEID

What is returned will be:
[tt]
CONTACT | PHONEID | PHONE
Chad Horton 1 480-555-1212
Chad Horton 2 480-555-1213
[/tt]

Hope this helps. ICQ: 54380631
online.dll
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top