Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6080

table appears with empty rows, and row data appears before table. Code seems ok. What is going on?

From "kurtk@pobox.com" <kurtk@pobox.com>
Newsgroups comp.lang.php
Subject table appears with empty rows, and row data appears before table. Code seems ok. What is going on?
Date 2012-05-16 07:37 -0700
Organization http://groups.google.com
Message-ID <15449691.1592.1337179042368.JavaMail.geo-discussion-forums@ynja13> (permalink)

Show all headers | View raw


I have code which displays a HTML <table>. The data in the rows comes is read from a file. But the row data is appearing (minus the <tr></tr> tags) on the web page before the table. The table displays with empty rows below what was supposed to be the row data.

In other words this php...

echo "<table>\n<thead>\n<tr><th>number</th><th>date</th><th>First Name</th><th>Last Name</th><th>state</th><th>country</th><th>remarks</th></tr>\n</thead>\n<tbody>\n";

try {
      
   $fileh = fopen("data/petition-051512.csv", "r");
       
   while ($text = fgets($fileh)) {
       
        $tok = strtok($text, ",");

        while ($tok !== FALSE) {
            
             echo "<tr>" . $tok . "</tr>\n";

             $tok = strtok(",");
        } 
   }
   echo "</tbody></table>\n";
   return;

produces html that looks like one big mass of text, consisting of the 560 rows of data, minus any table tags, followed by a table with 560 empty rows. 

I can't figure this out.

Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

table appears with empty rows, and row data appears before table. Code seems ok. What is going on? "kurtk@pobox.com" <kurtk@pobox.com> - 2012-05-16 07:37 -0700
  Re: table appears with empty rows, and row data appears before table. Code seems ok. What is going on? Paul Herber <paul@pherber.com> - 2012-05-16 15:59 +0100
  Re: table appears with empty rows, and row data appears before table. Code seems ok. What is going on? Denis McMahon <denismfmcmahon@gmail.com> - 2012-05-16 20:23 +0000
    Re: table appears with empty rows, and row data appears before table. Code seems ok. What is going on? IRC <ircadhikari@gmail.com> - 2012-05-17 04:27 -0700
      Re: table appears with empty rows, and row data appears before table. Code seems ok. What is going on? Denis McMahon <denismfmcmahon@gmail.com> - 2012-05-17 14:45 +0000
        Re: table appears with empty rows, and row data appears before table. Code seems ok. What is going on? The Natural Philosopher <tnp@invalid.invalid> - 2012-05-17 18:37 +0100

csiph-web