| | |
not showing empty values coming from database
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2008
Posts: 74
Reputation:
Solved Threads: 0
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,
actully i have no idea how to do it...
please help..
//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
}please help..
•
•
Join Date: Jun 2009
Posts: 68
Reputation:
Solved Threads: 10
build tables, and
PHP Syntax (Toggle Plain Text)
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>";
Last edited by djjjozsi; Jun 16th, 2009 at 7:55 am.
•
•
Join Date: Oct 2007
Posts: 78
Reputation:
Solved Threads: 5
here is the simple solution:
this is just a example. modified your code according to your needs.
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.
Defeat the defeat before defeat defeats you.
•
•
Join Date: Jun 2009
Posts: 68
Reputation:
Solved Threads: 10
while ($row =mysql_query($result)) ????????
php Syntax (Toggle Plain Text)
<?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"]) ? " " : $rows_res["brandName"] )."</td>"; echo "<td>". ( empty($rows_res["model"]) ? " " : $rows_res["model"] )."</td>"; echo "<td>". ( empty($rows_res["modYear"]) ? " " : $rows_res["modYear"] )."</td>"; echo "<td>". ( empty($rows_res["regCity"]) ? " " : $rows_res["regCity"] )."</td>"; echo "<td>". ( empty($rows_res["demand"]) ? " " : $rows_res["demand"] )."</td>"; print "</tr>"; } print "</table>"; } else echo "No result in res table ..."; ?>
Last edited by djjjozsi; Jun 16th, 2009 at 10:07 am.
![]() |
Similar Threads
- Mutiple select drop down box ...... (JavaScript / DHTML / AJAX)
- How to avoid aa empty values in a text box (PHP)
- Database values in fopen path? (PHP)
- Populating Listbox with database table values (VB.NET)
- problem in accessin table values from access database.. (Java)
- collection_select with :selected option (Ruby)
- insert values to mysql database (JSP)
- asp with vbscript and javascript (ASP)
- passing empty string to SqlCommand.Parameter.Add (VB.NET)
Other Threads in the PHP Forum
- Previous Thread: problem with posting a variable
- Next Thread: Can't find line breaks
| Thread Tools | Search this Thread |
apache api array beginner binary body broken cakephp checkbox class cms code computing cron curl database date date/time delete display dynamic echo email error file files filter folder form forms function functions gc_maxlifetime global google host href htaccess html image include insert ip javascript joomla limit link list login mail memmory memory menu mlm msqli_multi_query multiple mycodeisbad mysql navigation oop parameter parsing paypal pdf php problem query radio random recourse recursion regex remote script search seo server sessions sms snippet source space sql static syntax system table thesishelp tutorial update upload url validator variable video web webdesign wordpress xml youtube





