I want to know how to split a very long html page into a number of small pages autmatically? - Very urgent?
Hi, I have a collection of data which has been permitted to use in my own website. It has been given to me as a html page with single a table having 1500 rows.
The page takes a long time to load in the browser and even if I open it in excel, it takes a really long time for every single change I make.
Now, I want to split this one file into several html files so that each page may have a table which has just 20 rows from the long table in the actual file. I can then link to all these pages in every page using numbers.
I am new to website designing and I just use ready made templates and free javascript codes to design my site. Is there any easy way to do what I want to do. This is very urgent and I am waiting for a best answer.
Public Comments
- If you have a database available, you can just import all those 1500 rows of data into it and look for the codes online on how to do a simple pagination. If you are just creating plain HTML website then you have to manually split the tables and save them as individual pages. Lets say you want to show only 20 rows at a time, you will name the page as "table_p1.html". At the end of the table you will create a "Next" button which upon click will go to the next page of 20 rows, "table_p2.html".
- You probably ends up writting a small piece of codes. Since i dont know your html codes. The best i can come up with is that <?php $fp = fopen("file.html","r"); $i=1; $fp1 = fopen("0.html","w"); $bool = 0; while (($line = fgets($fp))!=EOF) { if(i%21==0) { fclose($fp1); $fp1 = fopen("$i%21".".html","w"); $i=1; } if(preg_match("/<tr/i",$line)) //check the line if contains HTML tag of new row bool = 1; //now look for the close tag } if(preg_match("/<\/tr/i", $line ) && $bool=1)//found the close tag { $bool = 0; fclose(fp1); fwrite(fp1,"</table></body></html>"); $fp1 = fopen("$i%20".".html","w"); fwrite(fp1,"<html><body><table>"); } fclose(fp); ?> Make sure you have php interpreter. Ask some one who know how to run this php script. I dont guarantee that this codes will run on your HTML but with minor change it should work
- lol nerdfc hit the nail on the head.
Powered by Yahoo! Answers