homepage Welcome to WebmasterWorld Guest from 54.163.91.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

    
Show table grid even if no data in cell
lmayer4




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

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

 

slade7




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

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

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

lmayer4




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

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

Fotiman




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

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

slade7




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

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

lmayer4




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

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

Laura

Robin_reala




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved