Welcome to WebmasterWorld Guest from 54.145.104.199

Forum Moderators: not2easy

Message Too Old, No Replies

Show table grid even if no data in cell

     
3:15 pm on Dec 29, 2005 (gmt 0)

5+ Year Member



Morning,

I am trying to create table from a database that needs to be printed out. What happens now is the data comes out fine but the table only shows the lines if there is data in the table. Is there a way to do this so all the grid lines show up regardless?

Thanks

Laura

3:37 pm on Dec 29, 2005 (gmt 0)

10+ Year Member



Have your script stick an   in any cells that are empty. If you are using php, it's

if(empty($foo)){
$foo = " ";
}

3:49 pm on Dec 29, 2005 (gmt 0)

5+ Year Member



Like so?

mssql_data_seek ($result, 0);
while ($row = mssql_fetch_assoc ($result)) {
echo "<tr>\n";
foreach ($row as $column)
{
if(empty($column))
{
$column= "&nbsp;";
}
else
{
echo "<TD>$column</TD>\n";
}
echo "</TR>\n";
}

3:56 pm on Dec 29, 2005 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Like so:

mssql_data_seek ($result, 0);
while ($row = mssql_fetch_assoc ($result)) {
echo "<tr>\n";
foreach ($row as $column)
{
if(empty($column))
{
$column= "&nbsp;";
}

echo "<TD>$column</TD>\n";

echo "</TR>\n";
}

4:08 pm on Dec 29, 2005 (gmt 0)

10+ Year Member



Fotiman is right - you want to echo it either way. All the if statement should to is set $column = "&nbsp" IF the variable $column is empty

In yours it would not echo a <TD> at all if $column is empty

4:25 pm on Dec 29, 2005 (gmt 0)

5+ Year Member



Thanks so much! That works perfect. Thanks again for all the help.

Laura

5:34 pm on Dec 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ideally you should be able to do:

table { empty-cells: show; }

instead of adding an nbsp entity, but I've no idea what browser support is like.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month