Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2007-04-04, 08:34 PM
Junior Member
 
Join Date: May 2006
Posts: 4
Francis_htli is on a distinguished road
Default problem with the output format

Here's the PHP code

<?php
$sql="select b.company, b.address, b.city, b.province, b.postcode, b.phone, b.fax, a.firstname, a.lastname, a.email, a.title, a.accountid FROM m_users a, CG_branch_profile b where a.accountid=b.account order by b.company, b.address, b.city, b.province, b.postcode, b.phone, b.fax";

$result=mysql_query($sql, $dblink);
while ($result1=mysql_fetch_array($result)) {

echo "<table border='1' width='100%'><tr><td>";
echo $result1['branch'];
echo "<BR>";
echo $result1['company'];
echo "<br>";
echo $result1['address'];
echo "<br>";
echo $result1['city'];
echo ", ";
echo $result1['province'];
echo " ";
echo $result1['postcode'];
echo "<br>Telephone: ";
echo $result1['phone'];
echo "<br>Fax: ";
echo $result1['fax'];
echo "</td></tr><tr><td>";
echo $result1['firstname'];
echo " ";
echo $result1['lastname'];
echo ", ";
echo $result1['email'];
echo ", ";
echo $result1['title'];
echo "</td></tr></table>";


}
?>

The following is the output:

ABC INC.
123 - 167 ST.
EDMONTON, Alberta T5M 9U7
Telephone: (780) 589-4589
Fax: (780) 589-1897
Richard king, king@abc.ca, Technical Support Spe******t
ABC INC.
123 - 167 ST.
EDMONTON, Alberta T5M 9U7
Telephone: (780) 589-4589
Fax: (780) 589-1897
Curtis King, , Product Manager
ABC INC.
123 - 167 ST.
EDMONTON, Alberta T5M 9U7
Telephone: (780) 589-4589
Fax: (780) 589-1897
Andrew King, kinga@abc.ca, Product Manager

What do I need to change to the php code that generate the following output?
ABC INC.
123 - 167 ST.
EDMONTON, Alberta T5M 9U7
Telephone: (780) 589-4589
Fax: (780) 589-1897
Richard king, king@abc.ca, Technical Support Spe******t
Andrew King, kinga@abc.ca, Product Manager
Curtis King, , Product Manager

Last edited by Francis_htli; 2007-04-04 at 08:41 PM.
Reply With Quote
  #2 (permalink)  
Old 2007-04-05, 01:54 AM
Senior Member
 
Join Date: Dec 2004
Posts: 199
strasm is an unknown quantity at this point
Default

ok, this is pretty easy. You have a pretty complex query; I would try and break the query into to separate queries. The first query for the general data, then the second query will be a loop that will go for each contact. like this.

Code:

while($result2 = mysql_fetch_array($result)){
  echo "<tr><td>";
  echo $result1['firstname'] ." " .$result1['lastname'] .", " .$result1['email']. ", " .$result1['title'];
  echo "</td></tr>";
}
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:31 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.