Page 1 of 4 123 ... LastLast
Results 1 to 10 of 37

Thread: copy a table

  1. #1
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default copy a table

    I will like to copy a table being from another site to put it on my page.
    Thus if the table of the external site is modified, my table changes alone while being based on the other.

    Is this possible?


    ps: excuse me for my english but i speak french

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It is possible, using PHP.

    <?php include('http://the.com/the/page.htm'); ?>

    That would include the whole page into your page where that code is. I would suggest having just the table in a document.

    For example:

    table.txt:
    <table>...my data here...</table>

    On both page 1 and page 2:
    <?php include('table.txt'); ?>

    It would be a lot more work to first extract the table and then place it into a new page. If you need this, we can probably help, though.
    You could use file_get_contents('the.txt') and then split it using string functions, like substr, strpos, etc.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    in fact the problem is that I is not the possibility of modifying the source page in which the table is that I have need.
    Thus it will be necessary that I make a which page either duplicates the table, or that information of table source sent directly in my base of data so that don&#233;es replace themselves in the new table.

    (if that is possible with another language that the php, that will also go)

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    No reason to use another language. you need a serverside language, like PHP, and there's nothing wrong with using PHP.

    It's just hard.

    <?php
    $f = file_get_contents('http://whatever.com/stuff/page.htm');
    echo substr($f,strpos($f,'<table>'),strpos($f,'</table>',strpos($f,'<table>'))-strpos($f,'<table>'));
    ?>

    That will find the first instance of the characters "<table>" in the source code of that page, and continue until the first instance after of "</table>".

    This isn't very reliable, though, because you must find the RIGHT instance of the table and the right close tag. I suggest looking at those two functions, strpos and substr, and finding a way to use them to find the right table on the page.
    If you happen to know it says "options:" and the table is after that, for example, you could use that as a marker, and make sure that it only finds results after "options:".
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thus that will enable me to find the beacon table
    do I have compri well?

    here there is plusior table on the page, and that which I have need, is not the first.

    Thus thanks must then to the name to give to the table, I have easy not?

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You must find a way to distinguish the table.
    Find a set of characters in the source code that will always be there and is as close as possible to the table you want.
    You could link to the page and I could check.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    apparently it is identical table with each time a beacon <br> enters

    but it is a table has two lines.

    Thus perhaps that I can use the first line containing the title of the table in order to copy the second line which contains the essential contents

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Sure.
    You need a CLEAR marker that will never change, and you can get any data you want in relation to that.

    The computer doesn't see tables. It just sees characters. So you can tell it to look for "t" before "a" before "b" before "l" before "e", etc., but it won't be able to guess what you want.

    You will need a clear marker before and after (after can be less clear as long as it is the first instance after the start), or a position and length, etc.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  9. #9
    Join Date
    Aug 2007
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thus I can say to him to take into account of beacon TD being after such word text (as the title) until the end of this beacon.

    Is this well that?
    Last edited by byronghislain; 08-17-2007 at 09:51 PM.

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The computer doesn't see tables. It just sees characters.
    Unless you use a DOM parser. Then it sees elements.
    <?php include('http://the.com/the/page.htm'); ?>
    Now this is a very bad idea. That HTML page will be included -- and executed as PHP code. It effectively gives the owner of the remote server access to your server with the access rights of the server process -- which is enough to much up your files and probably steal a database password or two, at least.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •