homepage Welcome to WebmasterWorld Guest from
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 / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Strange HTML table display issue after mysql data seek

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

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?


[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)

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)

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)

sounds aggravating ;)

good catch


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

Yes. Aggravating. hehe

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
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