Need help diplaying null values

Reply

Join Date: Mar 2005
Posts: 2
Reputation: eyelove808 is an unknown quantity at this point 
Solved Threads: 0
eyelove808 eyelove808 is offline Offline
Newbie Poster

Need help diplaying null values

 
0
  #1
Mar 23rd, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 348
Reputation: paradox814 is an unknown quantity at this point 
Solved Threads: 4
paradox814's Avatar
paradox814 paradox814 is offline Offline
Posting Whiz

Re: Need help diplaying null values

 
0
  #2
Mar 23rd, 2005
  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.  
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 2
Reputation: eyelove808 is an unknown quantity at this point 
Solved Threads: 0
eyelove808 eyelove808 is offline Offline
Newbie Poster

Re: Need help diplaying null values

 
0
  #3
Mar 23rd, 2005
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!");
}
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 50
Reputation: barnamos is an unknown quantity at this point 
Solved Threads: 0
barnamos's Avatar
barnamos barnamos is offline Offline
Junior Poster in Training

Re: Need help diplaying null values

 
0
  #4
Mar 24th, 2005
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?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC