i am getting the list of values from databas table, some values are null, i want to show the values, which are not null. example is as follow,

//sql query 
while ($row =mysql_query($result))
{
$carBrand     =$row['brandName'];
$carMod        = $row['model'];
$carModYear =$row['modYear'];
$regCity        =$row['regCity'];
$demand      =$row['demand'];
//some of them are null, i want to print here only those are not null
}

actully i have no idea how to do it...
please help..

build tables, and

print "<tr>";
echo "<td>". ( empty($row["brandName"]) ? "-" : (htmlspecialchars($row["brandName"])) )."</td>";
echo "<td>". ( empty($row["model"]) ? "-" : (htmlspecialchars($row["model"])) )."</td>";
echo "<td>". ( empty($row["modYear"]) ? "-" : (htmlspecialchars($row["modYear"])) )."</td>";
echo "<td>". ( empty($row["regCity"]) ? "-" : (htmlspecialchars($row["regCity"])) )."</td>";
echo "<td>". ( empty($row["demand"]) ? "-" : (htmlspecialchars($row["demand"])) )."</td>"; 
print "</tr>";

here is the simple solution:

while ($row =mysql_query($result))
{
if(!empty($row['brandName'])
{
$carBrand     =$row['brandName'];
}
if(!empty($row['model'])
{
$carMod        = $row['model'];
}
---
---
---
}

this is just a example. modified your code according to your needs.

while ($row =mysql_query($result)) ????????

<?php
	include("conn_bd.php");
    $sql="select * from table";

    $result_res=mysql_query($sql) or die(mysql_error());
    print "<table border=\"1\">";
    if(mysql_num_rows($result_res)>0)
    {
        while($rows_res=mysql_fetch_assoc($result_res))
        {
            /* here comes the printed values*/
print "<tr>";
echo "<td>". ( empty($rows_res["brandName"]) ? "&nbsp;" : $rows_res["brandName"] )."</td>";
echo "<td>". ( empty($rows_res["model"]) ? "&nbsp;" : $rows_res["model"] )."</td>";
echo "<td>". ( empty($rows_res["modYear"]) ? "&nbsp;" : $rows_res["modYear"] )."</td>";
echo "<td>". ( empty($rows_res["regCity"]) ? "&nbsp;" : $rows_res["regCity"] )."</td>";
echo "<td>". ( empty($rows_res["demand"]) ? "&nbsp;" : $rows_res["demand"] )."</td>";
print "</tr>";
        }
        print "</table>";
    }
    else
    echo "No result in res table ...";

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.