Welcome, Guest. Please login or register for free.
Did you miss your activation email?
Friday 05 September 08 18:21 BST (UK)
Welcome Home Help Shop Search Calendar Login Register
Search Images 

Online
 
  First Name(s)

Last Name

 
News: Add and search your names to the all new RootsChat SURNAME INTERESTS TABLE today

+  RootsChat.Com
|-+  General
| |-+  The Common Room
| | |-+  Free RootsChat Webspace (Moderator: trystan)
| | | |-+  Creating tables?
« previous next »
Pages: [1] Print
Author Topic: Creating tables?  (Read 698 times)
kmo
RootsChat Senior
****
Offline Offline

Posts: 421



WWW
Creating tables?
« on: Sunday 01 October 06 21:03 BST (UK) »

I've been tinkering about seeing if i can create a webpage for a Family History Societies Members Interests.
Basically a table with six columns and a couple of thousand rows.
Aftera few false starts I made it in Word using the create a table function and saving the end result as a webpage.
It opens (eventually) in Internet Explorer and looks ok. If I open it with Notepad, the content is buried in reams of formatting!
My problem is the page is 2MB! A bit unwieldy? Any suggestions for lightening the load?
Logged
Zeb
RootsChat Senior
****
Offline Offline

Posts: 431



WWW
Re: Creating tables?
« Reply #1 on: Sunday 01 October 06 21:29 BST (UK) »

What is the source of the data inside the cells?

If you want this to be online then I suggest creating a database and writing a page in PHP to extract the data and show it in pages. The added advantage is that you can search the data as well.

The actual source would only be a few lines long as the PHP script would generate the HTML for you.
Code:
<table cellspacing="0" cellpadding="1" border="1">
<?php $query=mysql_query("SELECT * FROM tableindatabase ORDER BY `column` LIMIT 10,20");
while (
$fetch=mysql_fetch_array($query)) {
  echo '<tr><td>'.$fetch[0].'</td><td>'.$fetch[1].'</td><td>'.$fetch[2].'</td><td>'.$fetch[3].'</td><td>'.$fetch[4].'</td><td>'.$fetch[5].'</td></tr>';
}
?>

</table>
Thats very crude code but its the basic idea.
Logged

Derby: WOODCOCK (Donnington)
Devon: HARRIS (Plymouth)
Lancashire: DERRICK
Lincolnshire: CROPPER, WOODCOCK (Boston)
London: BARKER, DUGGIN, HARRIS, HINTON, HULBERT, WHITE
Wales: HARRIS, PRITCHARD (Pembrokeshire)
Warwickshire: DERRICK, WOODCOCK
Desperate for my Woodcocks from Birmingham!
Berlin-Bob
Global Moderator
RootsChat Marquessate
*******
Offline Offline

Posts: 5067


by My Daughter. Chatting to find her Roots !


Re: Creating tables?
« Reply #2 on: Tuesday 03 October 06 13:34 BST (UK) »

Hi kmo,

Zeb's solution is the best one for large databases, but if you don't fancy it, or there is no PHP on the site you are working on, then try this:

the basic table tags are these:

<table>start table</table>end table
<tr>start a line</tr>end a line
<td>start a cell</td>end a cell

so for a six column table, if you make this structure in Notepad, then you can use any "<tr> . . . </tr>" line as a template and repeat as often as you want.

<table border=1>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
:
:
:
:
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</table>

Replace the &nbsp; with your text for that cell.  Leave it in for empty cells, and then the borders will also be drawn.

It's monotous, rather than hard, and two thousand lines sound like a lot, but bit by bit, "stay after school and write a 100 lines" till it's all done  Grin Grin


Good luck,
Bob
Logged

Searching for Coleman, Moore, Kallnung in London; Margulies, Remenyi in E. Europe;
Ancestors of Hessie Stevenson-Coleman-Baxter (Ireland, 1861)
and, of course, any other ancestors for my web-site http://boco.rootschat.net

All Census Data included in this post is Crown Copyright (see: www.nationalarchives.gov.uk)
kmo
RootsChat Senior
****
Offline Offline

Posts: 421



WWW
Re: Creating tables?
« Reply #3 on: Tuesday 03 October 06 22:57 BST (UK) »

Thanks for the replies.
I have no problem making the table. Made it in Word, using the create a table function. Copy and pasted the data into it from a database and saved the finished article as a webpage. Word does all the formatting.
My problem is the size of the finished page.



* print_screen.gif (5.2 KB, 780x150 - viewed 115 times.)
Logged
Zeb
RootsChat Senior
****
Offline Offline

Posts: 431



WWW
Re: Creating tables?
« Reply #4 on: Tuesday 03 October 06 23:28 BST (UK) »

You could perhaps split it into sections like A, B, C, D etc. then that would give you 26 pages. I take it BRE is an area so maybe split it into areas?

Here's another idea...

If you can paste it all into Word can you paste it into an Excel spreadsheet? If you can its possible to save it out (export) as a CSV file. This is a plain text file which can then be used to insert into a MySQL database. The end product can be viewed any way you want in any order and you won't have loads of files on the server. Just a database and a couple of files.

Searching would be like:
1. abra* (show all starting with "abra")
2. *son (Show all ending in "son")
3. *son* (Show all containing "son")
4. bre (Show all columns containing "BRE")
The results can be displayed in alphabetical order or reverse order. You can search on anything including any in a certain year.

I've got a lot of spare time on my hands at the moment. All I'm doing is writing the RC Guestbook and waiting for work to start on a large retro website. If you want a hand with it PM me... Wink
Logged

Derby: WOODCOCK (Donnington)
Devon: HARRIS (Plymouth)
Lancashire: DERRICK
Lincolnshire: CROPPER, WOODCOCK (Boston)
London: BARKER, DUGGIN, HARRIS, HINTON, HULBERT, WHITE
Wales: HARRIS, PRITCHARD (Pembrokeshire)
Warwickshire: DERRICK, WOODCOCK
Desperate for my Woodcocks from Birmingham!
downside
RootsChat Aristocrat
******
Offline Offline

Posts: 2485


Make my day


WWW
Re: Creating tables?
« Reply #5 on: Saturday 07 October 06 12:23 BST (UK) »

Hi kmo

Word inserts a lot of xml code when it outputs your Word document as a webpage.  You could do as Bob says write your own HTML version using Notepad but you would have to do a lot of typing in order to insert all those HTML tags.  I know a way of doing this using a combimation of JavaScript and HTML but if you are not computer savvy then you might feel a little lost.

Basically you could create a comma separated file from your database program and save as text:

RowNumber,"1683","Abraham","Abraham","Llangyndir","BRE","1826+"

If you can, you should add a row number to each row starting at 0.

You then have to then add some JavaScript lines to your saved text file:

var individual = new Array() {
function record (fieldOne, fieldTwo,fieldThree,fieldFour,fieldFive,fieldSix)
{
this.firstOne = fieldOne;
this.fieldTwo = fieldTwo;
this.fieldThree = fieldThree;
this.fieldFour = fieldFour;
this.fieldFive = fieldFive;
this.fieldSix = fieldSix;
}

function createIndividual {

individual[0] = new record("1683","Abraham","Abraham","Llangyndir","BRE","1826+");

load of rows etc.

}

OK - so for each row you need to insert that row number between the square brackets.  At the very end of the file you must add a curly brace }.  Save the file as mytableDB.js.

Now you have to create a file that opens your database as a webpage.  We'll call it mytable.htm.

Enter the following code in a blank Notepad file:

<htm>
<head>
<script language="JavaScript" type="text/javascript" src="mytableDB.js"></script>
</head>
<body>
<script language="JavaScript" type="text/javascript">

createIndividual ();

document.write("<table border=1>");
for (i = 0 ; i < individual.length; i++)
{ document.write("<tr><td>" +individual[i]. fieldOne + "</td><td>" + individual[i].fieldTwo + "</td><td>" + individual[i].fieldThree + "</td><td>"  + individual[i].fieldFour + "</td><td>" + individual[i].fieldFive + "</td><td>"  + individual[i].fieldSix + "</td></tr>" ); }

document.write("</table>");
</script>
</body>
</html>

Now save the file as mytable.htm.

Effectively, the for loop will write your entire database to the screen.
The advantage of doing things this way is that you do not have to perform the tedious task of inserting all those <td> and </td> tags between each of the datafields as in a static HTML document.

If you have your data in an Access database then you could create an extra field when you output a query so that it contains:

individual[

followed by the row number field, and then another extra field

] = new record(

this will cut down on the amount of typing you would have to do.  You can also use the Search and Replace function within Notepad to reduce the amount of work you would have to do.

If you have empty data cells then you may need to insert "&nbsp;" into the mytableDB.js file so that the cells are properly formed.


downside
Logged

Sussex: Floate, West
Kent: Tuffee
Cheshire: Gradwell
Zeb
RootsChat Senior
****
Offline Offline

Posts: 431



WWW
Re: Creating tables?
« Reply #6 on: Saturday 07 October 06 21:13 BST (UK) »

downside, the main problem with that is that you have to get Excel (presuming the database is stored in Excel) to save the data out as a CSV file - thats the type of text file you're describing when you say to add commas between the data. If the data isn't stored in Excel then thats a LOT of converting to do.

Then there's the task or converting each line of data to javascript, ie:
Code:
individual[0] = new record("1683","Abraham","Abraham","Llangyndir","BRE","1826+");
and
more code for each line
Its a nice idea but as javascript is client-side the converting of all that data will only be as fast as the user's computer. If they're running other applications at the same time then it could take a long time.

If the data is stored in a CSV file then it might as well be uploaded and inserted into a MySQL database using a simple script then having a separate script to view the data. The second script would only be as complex as desired (ie. displayed in order of a set column, displayed by the user choosing which column, searching for data, paginating the display results etc.)

As PHP is server-side it frees the end user's computer up and removes the risk of one stray piece of data messing the entire display whereas PHP/MySQL would always return safe data.
Logged

Derby: WOODCOCK (Donnington)
Devon: HARRIS (Plymouth)
Lancashire: DERRICK
Lincolnshire: CROPPER, WOODCOCK (Boston)
London: BARKER, DUGGIN, HARRIS, HINTON, HULBERT, WHITE
Wales: HARRIS, PRITCHARD (Pembrokeshire)
Warwickshire: DERRICK, WOODCOCK
Desperate for my Woodcocks from Birmingham!
downside
RootsChat Aristocrat
******
Offline Offline

Posts: 2485


Make my day


WWW
Re: Creating tables?
« Reply #7 on: Saturday 07 October 06 23:37 BST (UK) »

Hi Zeb

I'm not sure what point you are trying to make about Excel.  In your first thread you suggest he uses Excel and then in your next you seem to think Excel is a problem.

If these JavaScripts are uploaded on to a server then they are being run server-side.

I just ran a test on my PC and it took a couple of seconds to execute and display a table containing just under a thousand rows.  I have a Pentium III with 256MB of RAM so I guess a dual-core with a couple of gigs of RAM would probably load even faster.

downside
Logged

Sussex: Floate, West
Kent: Tuffee
Cheshire: Gradwell
Zeb
RootsChat Senior
****
Offline Offline

Posts: 431



WWW
Re: Creating tables?
« Reply #8 on: Saturday 07 October 06 23:41 BST (UK) »

The Javascript you're using is CSJS (Client Side JavaScript) and will always be run on the client's computer. You may be adding the script into the HTML page and uploading it but the script will always be downloaded exactly as it is to the user's computer when the user requests the page. Once the page has come down the Javascript will be executed when called.

SSJS (Server Side JavaScript) requires different HTML tags (ie. <server> instead of <script>) to call it and works slightly differently.

If you read my replies a bit slower you'll see that I'm saying that if Excel is being used to store the data then a CSV file can be made by exporting. This can then easily be imported into a MySQL database.

EDIT: Tidied my grammar - read it back and it made little sense.
Logged

Derby: WOODCOCK (Donnington)
Devon: HARRIS (Plymouth)
Lancashire: DERRICK
Lincolnshire: CROPPER, WOODCOCK (Boston)
London: BARKER, DUGGIN, HARRIS, HINTON, HULBERT, WHITE
Wales: HARRIS, PRITCHARD (Pembrokeshire)
Warwickshire: DERRICK, WOODCOCK
Desperate for my Woodcocks from Birmingham!
kmo
RootsChat Senior
****
Offline Offline

Posts: 421



WWW
Re: Creating tables?
« Reply #9 on: Saturday 07 October 06 23:57 BST (UK) »

Word inserts a lot of xml code when it outputs your Word document as a webpage. 
Had a feeling that a lot of extra stuff had been added.  There were around 100 fonts in the beginning of the file.
As far as Excel goes, I don't have it on my PC. As jobs in Family History Societies tend to get swapped around every few years or so, it's important that files are kept in a form that any computer with basic  bundled software can read them. It saves the Society the cost of purchased  software.
Logged
Zeb
RootsChat Senior
****
Offline Offline

Posts: 431



WWW
Re: Creating tables?
« Reply #10 on: Sunday 08 October 06 00:03 BST (UK) »

So how is the data stored at the moment?
Logged

Derby: WOODCOCK (Donnington)
Devon: HARRIS (Plymouth)
Lancashire: DERRICK
Lincolnshire: CROPPER, WOODCOCK (Boston)
London: BARKER, DUGGIN, HARRIS, HINTON, HULBERT, WHITE
Wales: HARRIS, PRITCHARD (Pembrokeshire)
Warwickshire: DERRICK, WOODCOCK
Desperate for my Woodcocks from Birmingham!
downside
RootsChat Aristocrat
******
Offline Offline

Posts: 2485


Make my day


WWW
Re: Creating tables?
« Reply #11 on: Sunday 08 October 06 12:26 BST (UK) »

Hi kmo

You can obtain an Excel style spreadsheet that is included in a free office software package from open office http://www.openoffice.org/ if you are interested.

Back to your chief concern, the size of the table and length of time it takes to open.  If you want to load the entire table then it it is going to take a while for it to load.  You can make it smaller (in size) by following Bob's steps or my steps etc.  Our versions use less code than the Word xml document but even so it will take some time to load because of the amount of data involved.

Your alternative is break the data up into a series of linked pages.  If you had a 100 rows per page then you would have 20 pages.  As the first page would only be 100 rows it would load a lot faster.

If your plan is to have the whole doc loaded so that people can click of Edit and then Search on this page from the toolbar menu at the top of the browser screen then users will have to be patient while it loads.

downside
Logged

Sussex: Floate, West
Kent: Tuffee
Cheshire: Gradwell
Pages: [1] Print 
« previous next »


[Copyright] [Free RootsChat Webspace] [Your Surname Interests] [Shrink Link] [About Us] [Terms of Use]
All Census Lookups are Crown Copyright, National Archives for academic and non-commercial research purposes only
RootsChat.com cannot be held responsible directly or indirectly for the messages or content posted by others. Inline images in messages are the copyright of the respective linked sites.
RootsChat.com, Europa House, Bury, Lancashire, BL9 5BT
0.833:23