Trying to implement a nested loop in my code.
The code I have so far displays:
PracticeName...................................PracticeName2
Address...........................................Address
City, State Zip.................................City, State Zip
Phone#...........................................Phone #
Office Link........................................Office Link
The way I want it to look is, it displays all the names that pertain to that particular id;
PracticeName...................................PracticeName2
Address...........................................Address
City, State Zip.................................City, State Zip
Phone#...........................................Phone #
Name1............................................Name1
Name2
Name3
Office Link........................................Office Link
Here is the code that I have - a multicolumn display:
<?php
//set number of columns
$columns=2;
mysql_connect("localhost","root","");
mysql_select_db("db");
$query="SELECT distinct l.id, n.id, l.practicename, l.address1, l.city, l.abbrev, l.zip, l.phone, n.names FROM location l, names n WHERE l.id = n.id AND abbrev = 'MI' AND LineOfBusiness = 'General Practice' ORDER BY practicename";
$result=mysql_query($query);
$lineofbusiness='General Practice - Michigan';
$num_rows=mysql_num_rows($result);
echo "<table border=\"0\" align=\"center\" class=\"content10pt\" width=\"500\"><tr class=content10pt><td class=header2 align=center><br>$lineofbusiness</td></tr></table><table border=\"0\" align=\"center\" class=\"content10pt\" width=\"500\"><tbody><br>\n";
for($i=0;$i<$num_rows;$i++) {
$row=mysql_fetch_array($result);
if($i%$columns==0) {
echo "<tr class=\"content10pt\">\n";
}
echo "<td>" . $row['practicecname'] ."<br>" . $row['address1'] . "<br>" . $row['city'] . ", " . $row['abbrev'] . " " . $row['zip'] . "<br>" . "Phone: ". $row['phone'] . "<br><a href=http://./office_details2.php?id=".$row['id'].">Office Details</A><br><br><br>\n";
if(($i%$columns)==($columns-1) || ($i+1)==$num_rows) {
echo "</tr>\n";
}
}
echo "</tbody></table>\n";
?>
Not sure where to put the nested loop to display those Names. Please help. Thanks.