Welcome to WebmasterWorld Guest from 54.242.105.196

Forum Moderators: coopster & jatar k

Strange HTML table display issue after mysql data seek

   
9:09 pm on Jul 27, 2009 (gmt 0)

5+ Year Member


Hi,

First, the relevant code:

if ($result) {
echo '<table align="center" cellpadding="0" cellspacing="0" border="0">';
echo "<tr>\n";
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo '<td class="scroller" id="scroller'.$row[0].'">'.$row[1].'</td>';
}
echo "</tr>\n";
echo "<tr>\n";
mysql_data_seek($result, 0);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo '<td class="scroller" id="delete'.$row[0].'"><a href="javascript:deleteScroller(\''.$row[0].'\')">delete</a></td>';
}
echo "</tr>\n";
echo "</table>";
} else {
echo "Library quotes";
}

All this does is create a very simple table with only 2 rows. I loop through the same results twice, the second time after calling mysql_data_seek to reset the pointer. The data is correct when it's read by the php.

However, when it is displayed in the browser, the second row does not look like it's part of the same <table>! It looks like a new table has been created by the browser, or maybe it's nesting the second row inside the first somehow.

Weirder, the generated source code in the browser (View Source) looks fine, and when I paste that code into a dummy document, everything looks fine.

What am I missing?

Thanks,
Glenn

[1][[b]edited by[/b]: jatar_k at 2:44 pm (utc) on July 28, 2009][/1]
[1][edit reason] no personal urls please [url=http://www.webmasterworld.com/help.cgi?cat=tos]TOS[/url] [/edit][/1]

2:52 pm on Jul 28, 2009 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



there has to be something wrong with the html, did you try validating it? If the html 'looks fine' then throw a border on the table or something to see if you can make it show you what's up.

are all tr/td/table matched up?

are there stray divs? or divs at all?

something must change when you paste it into another doc, doctype?

4:04 pm on Jul 28, 2009 (gmt 0)

5+ Year Member



Argh. Figured it out.

In the CSS there was a left-over "float:left" from an earlier version of the layout.

4:12 pm on Jul 28, 2009 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



sounds aggravating ;)

good catch

4:28 pm on Jul 28, 2009 (gmt 0)

5+ Year Member



Yes. Aggravating. hehe

Everything looked fine (and validated fine) because I hadn't included the CSS in the test! As I said, Argh. hehe

 

Featured Threads

Hot Threads This Week

Hot Threads This Month