Current location: Hot Scripts Forums » Programming Languages » PHP » rookie question about blank fields

rookie question about blank fields

 
Prev Previous Post   Next Post Next
  #4  
Old 11-03-09, 06:46 PM
Jcbones Jcbones is offline
Coding Addict
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 281
Thanks: 3
Thanked 5 Times in 5 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
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Injecting a string into an If Statement ? nova912 PHP 4 07-21-06 03:04 PM
Form Validation - Prevent submit if fields are blank Cepeleon JavaScript 2 03-15-05 05:33 PM
formmail problem gscraper Perl 12 08-27-04 04:06 AM
Remove Duplicate and Blank Fields digitalje5u5 PHP 6 08-06-04 03:29 PM


All times are GMT -5. The time now is 08:59 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 (Unregistered)