homepage Welcome to WebmasterWorld Guest from 50.16.112.199
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
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

5+ Year Member



 
Msg#: 8116 posted 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

10+ Year Member



 
Msg#: 8116 posted 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

5+ Year Member



 
Msg#: 8116 posted 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

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 8116 posted 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

10+ Year Member



 
Msg#: 8116 posted 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

5+ Year Member



 
Msg#: 8116 posted 4:25 pm on Dec 29, 2005 (gmt 0)

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

Laura

Robin_reala

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 8116 posted 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