473,385 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

When a field value is empty how do you not show it...

Hi thanks for the help in advanced!.. To further explain what i want it to
do is:

go from:

Body Conscious
1815 Division St # 101
Nashville TN, 37203
615-321-8555
<blank field>
Touching Nashville since 1989, seven days a week.
to:

Body Conscious
1815 Division St # 101
Nashville TN, 37203
615-321-8555
Touching Nashville since 1989, seven days a week.

below is the code that I've been trying to work with:
<?php
$color1 = "#FFFFFF";
$color2 = "#FFFFCC";
$row_count = "0";

$query = mysql_query("SELECT DISTINCT * FROM itl WHERE city='$city2'
AND state='$state2' ORDER BY company") or die (mysql_error());
if (mysql_num_rows($query) < 1) { echo ''; }
while ($row = mysql_fetch_assoc($query)) {
$row_color = ($row_count % 2) ? $color1 : $color2;

?>
<tr>
<td width="400" bgcolor="<?php echo
$row_color; ?>"><ul>
<?php
echo('<font size="1" face="Verdana, Arial,
Helvetica,
sans-serif"><b>' . $row['company'] . '</b>' . '<br>' .
$row['address'] . '<br>' . $row['city'] . ' ' . $row['state'] . ', '
.. $row['zip'] . '<br>' . $row['phone'] . '<br>' . '<a href="http://'

.. $row['website'] . '">' . $row['website'] . '</a><br>' .

$row['description'] . '</font></li></p>');
?>
</ul></td>
</tr>
<?php
$row_count++;
}
}
?>

Jul 17 '05 #1
2 1598
ph*********@comcast.net wrote:
Hi thanks for the help in advanced!.. To further explain what i want it to
do is:

go from:

Body Conscious
1815 Division St # 101
Nashville TN, 37203
615-321-8555
<blank field>
Touching Nashville since 1989, seven days a week.
to:

Body Conscious
1815 Division St # 101
Nashville TN, 37203
615-321-8555
Touching Nashville since 1989, seven days a week.

below is the code that I've been trying to work with:
<?php
$color1 = "#FFFFFF";
$color2 = "#FFFFCC";
$row_count = "0";

$query = mysql_query("SELECT DISTINCT * FROM itl WHERE city='$city2'
AND state='$state2' ORDER BY company") or die (mysql_error());
if (mysql_num_rows($query) < 1) { echo ''; }
while ($row = mysql_fetch_assoc($query)) {
$row_color = ($row_count % 2) ? $color1 : $color2;

?>
<tr>
<td width="400" bgcolor="<?php echo
$row_color; ?>"><ul>
<?php
echo('<font size="1" face="Verdana, Arial,
Helvetica,
sans-serif"><b>' . $row['company'] . '</b>' . '<br>' .
$row['address'] . '<br>' . $row['city'] . ' ' . $row['state'] . ', '
. $row['zip'] . '<br>' . $row['phone'] . '<br>' . '<a href="http://'

. $row['website'] . '">' . $row['website'] . '</a><br>' .

$row['description'] . '</font></li></p>');
?>
</ul></td>
</tr>
<?php
$row_count++;
}
}
?>


Try something like this:

<?php
$color1 = "#FFFFFF";
$color2 = "#FFFFCC";
$row_count = "0";

$query = mysql_query("SELECT DISTINCT * FROM itl WHERE city='$city2'
AND state='$state2' ORDER BY company") or die (mysql_error());

if (mysql_num_rows($query) < 1) { exit; }

while ($row = mysql_fetch_assoc($query)) {
$row_color = ($row_count % 2) ? $color1 : $color2;
?>

<tr bgcolor="<?php echo $row_color; ?>">
<td width="400">
<font size="1" face="Verdana, Arial, Helvetica, sans-serif">

<?php
if ($row["company"] != "") { echo "<b>".$row["company"]."</b>" }
if ($row["address"] != "") { echo "<br>".$row["address"] }
if ($row["city"] != "") { echo "<br>".$row["city"] }
if ($row["state"] != "") { echo " ".$row["state"] }
if ($row["zip"] != "") { echo ", ".$row["zip"] }
if ($row["phone"] != "") { echo "<br>".$row["phone"] }
echo "<br>".'<a href="http://';
if ($row["website"] != "") { echo $row["website"].'">'.$row["website"] }
echo "</a>";
if ($row["description"] != "") { echo "<br>".$row["description"] }
?>

</font>
</td>
</tr>

<?php
$row_count++;
}
?>
Jul 17 '05 #2
<ph*********@comcast.net> wrote in message
news:BD440097.719A%ph*********@comcast.net...
Hi thanks for the help in advanced!.. To further explain what i want it to
do is:

go from:

Body Conscious
1815 Division St # 101
Nashville TN, 37203
615-321-8555
<blank field>
Touching Nashville since 1989, seven days a week.
to:

Body Conscious
1815 Division St # 101
Nashville TN, 37203
615-321-8555
Touching Nashville since 1989, seven days a week.

below is the code that I've been trying to work with:
<?php
$color1 = "#FFFFFF";
$color2 = "#FFFFCC";
$row_count = "0";

$query = mysql_query("SELECT DISTINCT * FROM itl WHERE city='$city2'
AND state='$state2' ORDER BY company") or die (mysql_error());
if (mysql_num_rows($query) < 1) { echo ''; }
while ($row = mysql_fetch_assoc($query)) {
$row_color = ($row_count % 2) ? $color1 : $color2;

?>
<tr>
<td width="400" bgcolor="<?php echo
$row_color; ?>"><ul>
<?php
echo('<font size="1" face="Verdana, Arial, Helvetica,
sans-serif"><b>' . $row['company'] . '</b>' . '<br>' .
$row['address'] . '<br>' . $row['city'] . ' ' . $row['state'] . ', '
. $row['zip'] . '<br>' . $row['phone'] . '<br>' . '<a href="http://'

. $row['website'] . '">' . $row['website'] . '</a><br>' .

$row['description'] . '</font></li></p>');
?>
</ul></td>
</tr>
<?php
$row_count++;
}
}
?>


For situation like this I like to stick the variables into an array, run it
through array_filter(), then either loop through it or hand it to implode().
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: jason | last post by:
Access 2000 I need some help interogatting a table and extracting via ASP the final field in a row which has a value. In other words, I have a maximum of 10 fields but, at the user level he may...
2
by: Robin | last post by:
Ok, I have a form that on clicking of the Update button first updates the specific record in the db, then Inserts if the vMemo field is not empty. The problem that I'm having is that After...
6
by: WindAndWaves | last post by:
Hi Gurus In my quest in putting my first javascript together, I am now trying to conquer something that seems trivial, but has taken me hours. I would like to format a field in a form once the...
11
by: Alan Silver | last post by:
Hello, I am using this validator on a textbox, and have discovered that if I set the InitialValue property, then the validator correctly fires if the user does not change the initial value of...
6
by: Mark Kamoski | last post by:
Hi Everyone-- Please help. What is the difference between a Field and a Property? Here is the context. In the VS.NET 2002 documentation, in the "String Members" section, we have the...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
3
by: JaRudzik | last post by:
Hello Try to add some blank text field and refresh window in IE it is ok but in firefox input hide_show works wrong , why ? Somebody can help me ? I'm not good in JS beacause I'm PHP coder ...
3
by: jmarr02s | last post by:
Hi, How do I replace with when the field is empty? Thanks! jmarr02s
12
by: lawrence k | last post by:
I've a form that starts off like this: <form method="post" action="profile.php? id=5&formName=my_story_edit.htm" enctype="multipart/form-data"> <p>Email address:<br /> <input type="text"...
7
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.