| | |
Need help diplaying null values
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2005
Posts: 2
Reputation:
Solved Threads: 0
I have a form on my site where members fill in info etc... This info goes into my database, I call to my DB to display this info in a table. My problem is that when someone does not fill in one of the spots in the form this goes to the DB as null and wont show up in my table, this makes my whole table get messed up and won't line up with the users information. My question is how can I get the null values to display null or show up blank in the table cell?
Here is the code I have would I put it
Here:
$sql="select id, name, email from update_table order by id";
Or in the actual table:
<table><td><tr>
<a href="profile.php?user=<?echo $row2['id'];?>"><?echo $row2['username'];
</tr></td?</table>
I have been trying to figure this out for weeks. Someone please help me out.
Here is the code I have would I put it
Here:
$sql="select id, name, email from update_table order by id";
Or in the actual table:
<table><td><tr>
<a href="profile.php?user=<?echo $row2['id'];?>"><?echo $row2['username'];
</tr></td?</table>
I have been trying to figure this out for weeks. Someone please help me out.
PHP Syntax (Toggle Plain Text)
$query ="select id, name, email from update_table order by id"; $result = mysql_query($query); if ($result == 0) { echo "there was an error accessing the database!"); } else { for ($i=0; $i<mysql_num_rows($result); $i++) { $row = mysql_fetch_row($result); echo "<table><td><tr>\n"; echo "<a href=\"profile.php?user=".$row[0]."\">".$row[1]."</a> echo "anything else needed .... yadda yadda yadda "; } }
Easiest thing to do is to alter your table to have a default value of "blank" rather than NULL. Then you don't have the problem.
However, I don't see that you would have a problem unless you are using if's on the results. If your while loop is something like this:
<table><?
while ($array = mysql_fetch_array($qry)) { ?>
<tr>
<td><? echo $array[id];?></td>
<td><? echo $array[name];?></td>
<td><? echo $array[hooha];?></td>
</tr><?
} >
</table>
A null value won't mung up the format in the above. How are you killing your table?
However, I don't see that you would have a problem unless you are using if's on the results. If your while loop is something like this:
<table><?
while ($array = mysql_fetch_array($qry)) { ?>
<tr>
<td><? echo $array[id];?></td>
<td><? echo $array[name];?></td>
<td><? echo $array[hooha];?></td>
</tr><?
} >
</table>
A null value won't mung up the format in the above. How are you killing your table?
![]() |
Similar Threads
- Null values from database causing fatal error (PHP)
- Need help with NULL values (ColdFusion)
- datagrid replacing null values (VB.NET)
- how to select null values in condition (MySQL)
- Exception Data is Null. This method or property cannot be called on Null values. (VB.NET)
- help with polymorphism and inheritance...getting null values (Java)
Other Threads in the PHP Forum
- Previous Thread: Am I looking for PHP?
- Next Thread: RSS Feeds Question
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dropdown dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





