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;?>"><?echo $row2;
</tr></td?</table>

I have been trying to figure this out for weeks. Someone please help me out. :confused:

$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 ";
   }
}

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!");
}

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?

This article has been dead for over six months. Start a new discussion instead.