View Single Post
  #4 (permalink)  
Old 11-03-09, 06:46 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
Try this:

PHP Code:

<?php
include("connect.php");
mysql_connect(localhost,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM resellers WHERE state='CA' ORDER BY city, coname";
$result=mysql_query($query);
$num=mysql_numrows($result);
if(
$num 0) {
  echo 
'<table>';
    while (
$r mysql_fetch_assoc($result)) {
        
$coname=$r["coname"];
        
$contactfirst=$r["contactfirs t"];
        
$contactlast=$r["contactlast" ];
        
$address1=$r["address1"];
        
$address2=$r["address2"];
        
$city=$r["city"];
        
$state=$r["state"];
        
$zip=$r["zip"];
        
$phone=$r["phone"];
        
$country=$r["country"];
        
$URL=$r["URL"];
        
$insurance=$r["insurance"];
        
$accreditation=$r["accreditat ion"];
        
$certfitter=$r["certfitter"];

    
            if(!empty(
$city)) { 
                echo 
'<tr>'."/n"
                            
.'<td colSpan="2"><h6>' $city '</h6></td>'."/n"
                        
.'</tr>'."/n";
            }
            if(!empty(
$coname) || !empty($certfitter)) {
                echo 
'<tr>'."/n";
                if(!empty(
$coname)) {
                    echo 
'<td><strong>' $coname '</strong></td>'."/n";
                }
                if(!empty(
$certfitter)) {
                    echo 
'<td>' $certfitter '</td>'."/n";
                }
                echo 
'</tr>'."/n";
            }
            if(!empty(
$contactfirst) || !empty($contactlast) || !empty($insurance)) {
                echo 
'<tr>'."/n";
                if(!empty(
$contactfirst) || !empty($contactlast)) {
                    echo 
'<td>' $contactfirst." ".$contactlast '</td>'."/n";
                }
                if(!empty(
$insurance)) {
                    echo 
'<td>' $insurance '</td>'."/n";
                }
                echo 
'</tr>'."/n";
            }
            if(!empty(
$address1) || !empty($address2) || !empty($accreditation)) {
                echo 
'<tr>'."/n";
                if(!empty(
$address1) || !empty($address2)) {
                    echo 
'<td>' $address1." ".$address2 '</td>'."/n";
                }
                if(!empty(
$accreditation)) {
                echo 
'<td>' $accreditation '</td>'."/n";
                }
                echo 
'</tr>'."/n";
            }
            if(!empty(
$city) || !empty($state) || !empty($zip)) {
                echo 
'<tr>'."/n"
                            
.'<td colSpan="2">' $city.", ".$state." ".$zip '</td>'."/n"
                        
.'</tr>'."/n";
            }
            if(!empty(
$phone)) {
                echo 
'<tr>'."/n"
                            
.'<td colSpan="2">' $phone '</td>'."/n"
                        
.'</tr>';
            }
            if(!empty(
$URL)) {
                echo 
'<tr>'."/n"
                            
.'<td colSpan="2"><a href="http://' $URL '">' $URL '</a></td>'."/n"
                        
.'</tr>'."/n";
            }
            echo 
'<tr>'."/n"
                        
.'<td colSpan="2"></td>'."/n"
                    
.'</tr>'."/n"
                    
.'<tr colspan="2"><td>&nbsp;</td></tr><br>'."/n"

                    
.'</tbody>'."/n";

    }
} else {
    echo 
'No rows returned from database';
}
mysql_free_result($result);
echo 
"</table>";
?>

Last edited by Jcbones; 11-03-09 at 06:49 PM.
Reply With Quote