944,039 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3570
  • PHP RSS
Mar 23rd, 2005
0

Need help diplaying null values

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eyelove808 is offline Offline
2 posts
since Mar 2005
Mar 23rd, 2005
0

Re: Need help diplaying null values

PHP Syntax (Toggle Plain Text)
  1. $query ="select id, name, email from update_table order by id";
  2. $result = mysql_query($query);
  3. if ($result == 0)
  4. {
  5. echo "there was an error accessing the database!");
  6. }
  7. else
  8. {
  9. for ($i=0; $i<mysql_num_rows($result); $i++)
  10. {
  11. $row = mysql_fetch_row($result);
  12. echo "<table><td><tr>\n";
  13. echo "<a href=\"profile.php?user=".$row[0]."\">".$row[1]."</a>
  14. echo "anything else needed .... yadda yadda yadda ";
  15. }
  16. }
  17.  
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
Mar 23rd, 2005
0

Re: Need help diplaying null values

I tried that and it does not work. This is where I put it:

$result1=@mysql_query($sql,$con) or die("woops! not successful 1<br> $sql");
if ($result == 0)
{
echo "there was an error accessing the database!");
}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eyelove808 is offline Offline
2 posts
since Mar 2005
Mar 24th, 2005
0

Re: Need help diplaying null values

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?
Reputation Points: 15
Solved Threads: 0
Junior Poster in Training
barnamos is offline Offline
50 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Am I looking for PHP?
Next Thread in PHP Forum Timeline: RSS Feeds Question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC