You are here: Re: for loops.....code breaks « PHP Programming Language « IT news, forums, messages
Re: for loops.....code breaks

Posted by Jeff North on 11/04/05 07:38

On 3 Nov 2005 16:26:33 -0800, in comp.lang.php "Hemanth"
<hemanth.singamsetty@gmail.com> wrote:

>| Hello there,
>|
>| I'm trying to read an excel worksheet (with more than 5000 rows and 30
>| columns) using PHP. I'm using the "excelreader" script I found over the
>| web - http://sourceforge.net/projects/phpexcelreader/.
>|
>| Seems to me, the script reads the values in all cells correctly and
>| stores the total number of rows and columns existing in the worksheet
>| (For example, in the excel file I'm using - total rows: 5375 and cols:
>| 37). The problem is when I try to print the values as a HTML table
>| (using two for loops), the script prints only first 236 rows and stops
>| execution. The following is the code snippet I use:
>|
>| for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++)
>| {
>| echo "<TR>";
>| for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
>| {
>| echo "<TD>".$data->sheets[0]['cells'][$i][$j];
>| }
>| echo "<BR>";
>| }

You might want to put a closing </td> and </tr> at the end of your
statements. You could get away with this years ago but browsers are
becoming more unforgiving (thank goodness).

>| I've also set the script execution time to 5-10 mins using
>| "set_time_limit" function, but the script still ends after printing 236
>| rows (takes less than a minute). I spot checked the cell values by
>| printing values from 300 to 500, 5200 to 5375 etc. The values seems to
>| okay and stored correctly in the arrays. From what I understood, the
>| for loops doesn't execute completely and I don't understand why?
>|
>| I've also created a small test script to see if the loops work and the
>| following code breaks...I don't see a output.
>|
>| <?php
>| set_time_limit(300);
>|
>| for ($i = 1; $i <= 5000; $i++)
>| {
>| for($j = 1; $j <= 40; $j++)
>| {
>| $data[$i][$j] = "mycell - $i$j"; //. ($i * $j);
>| }
>| }
>| echo "PRINTING TABLE....<BR>";
>|
>| echo "<table border='1'>";
>| for ($i = 1; $i <= 1000; $i++)
>| {
>| echo "<TR><TD>[$i]";
>| for($j = 1; $j <= 20; $j++)
>| {
>| echo "<TD>". $data[$i][$j];
>| }
>| echo "<BR>";
>| }
>| echo "</table>";
>| ?>
>|
>| Can anyone throw some light on it. Appreciate your help.
>|
>|
>| TIA,
>| Hemanth
>|
>| P.S: I'm using IE5.5, PHP4.1.2, Firefox1.0.4
---------------------------------------------------------------
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация