chordsoflife Posted March 1, 2009 Share Posted March 1, 2009 I'm outputting address and phone number info from a database. In one situation, one person has two phone numbers. The result of outputting is that the person with two phone numbers is displayed twice, each with one number. I want the person to be displayed once, with both numbers. Is there a simple way to do that? Here's the code: $people = mysql_query("SELECT pkPersonID, fldFirstName, fldLastName, fldNumber, fldPhoneType, fldBirthday FROM tblPerson, tblPhone, tblPersonPhone WHERE pkPersonID=fkPersonID AND pkPhoneID=fkPhoneID ORDER BY fldFirstName, fldLastName;", $conn); while($person = mysql_fetch_array($people, MYSQL_ASSOC)){ ?> <div class="entry"> <h2><?=ucwords($person[fldFirstName]);?> <?=ucwords($person[fldLastName]);?></h2> <p class="byline">DOB: <?=$person[fldBirthday];?></p> <p><?=formatPhoneNumber($person[fldNumber]);?> | <?=ucwords($person[fldPhoneType]);?></p> <p class="entryMenu"><a href="">Add A Number</a> | <a href="">Delete Entry</a></p> </div> <? } Quote Link to comment https://forums.phpfreaks.com/topic/147405-php-mysql-output-question/ Share on other sites More sharing options...
andy_b42 Posted March 1, 2009 Share Posted March 1, 2009 Can you provide more details of all of the fields in your tables. Quote Link to comment https://forums.phpfreaks.com/topic/147405-php-mysql-output-question/#findComment-773702 Share on other sites More sharing options...
chordsoflife Posted March 1, 2009 Author Share Posted March 1, 2009 I appreciate the help. Here's the create SQL for the tables I'm using: create table tblPerson (pkPersonID int primary key auto_increment,fldFirstName varchar(15),fldLastName varchar(15),fldBirthday date()); create table tblPhone (pkPhoneID int primary key auto_increment,fldNumber int); create table tblPersonPhone (fkPersonID int,fkPhoneID int,fldPhoneType varchar(15),fldPhoneOrder int); Quote Link to comment https://forums.phpfreaks.com/topic/147405-php-mysql-output-question/#findComment-773706 Share on other sites More sharing options...
chordsoflife Posted March 1, 2009 Author Share Posted March 1, 2009 Is this really a difficult question? If so, that kind of makes me nervous! Quote Link to comment https://forums.phpfreaks.com/topic/147405-php-mysql-output-question/#findComment-773824 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.