1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Data from another webpage/source

Discussion in 'PHP' started by sabahat, Mar 30, 2016.

  1. #1
    Hi Folks,

    Basically we have 10 websites. One particular page on all these website have same data. Its really painful when I have to update all the websites separately with same content.
    Can we have a separate webpage/source which could be edited and all the websites are automatically updated? probably like Stock prices are synched across all platforms.. not sure

    I am not very good at programming however I have good knowledge base of Wordpress (if that helps). if anyone can put me in right direction so I can accomplish that task. I have Lynda subscription (in case they have relevant tutorials)

    Thanks in advance,
    Sab
     
    sabahat, Mar 30, 2016 IP
  2. Host Capitol

    Host Capitol Greenhorn

    Messages:
    33
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    10
    #2
    You could use Server Side Includes to accomplish this.
     
    Host Capitol, Mar 30, 2016 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    Depending on how these pages are made, you could pull information from one file on one of the domains to the other domains, and parse it. Again, depends on the content how you would want to do that - if it's complex, maybe just make a HTML-file with the content, which you then can update, and include it via PHP on all the pages. Will require that the domain with the content-file is always available.
     
    PoPSiCLe, Mar 30, 2016 IP
  4. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #4
    I agree, using xml or json or just plain html that you fetch from a main server this could be done, but then you'll need to have some scripting (programming) experience... ;)
     
    EricBruggema, Mar 30, 2016 IP
  5. sabahat

    sabahat Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    HI Eric, Thanks for your reply. Could you please redirect me to any relevant tutorial? or give some step by step instructions on that.
     
    sabahat, Apr 1, 2016 IP
  6. sabahat

    sabahat Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    Thanks for your reply. How would I "pull" content from other website. what the process called? Could you please redirect me to any relevant tutorial? or give some step by step instructions on that.
     
    sabahat, Apr 1, 2016 IP
  7. Bitpalace

    Bitpalace Greenhorn

    Messages:
    53
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    13
    #7
    I recommend to avoid duplicate content altogether. It will have a negative impact on Google ranking for both of your sites.
     
    Bitpalace, Apr 1, 2016 IP
  8. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #8
    I had to check the date of your post... I thought maybe this was a reply from 1998
     
    NetStar, Apr 3, 2016 IP
    deathshadow and Bitpalace like this.
  9. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #9
    EricBruggema, Apr 10, 2016 IP
  10. Blizzardofozz

    Blizzardofozz Well-Known Member

    Messages:
    132
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    118
    #10
    You can use one DB and make connection from all websites to this DB or you can just paste links from all websites to your main website were this page is...? Plus it is not a good practice to have the same page on different sites.
     
    Blizzardofozz, Apr 11, 2016 IP
  11. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    818
    Best Answers:
    7
    Trophy Points:
    320
    #11
    The OP has TEN sites, NOT TWO sites, so if it has a negative impact on TWO of his sites, WHY won't it have a negative impact on the OTHER EIGHT of his sites????
     
    mmerlinn, Apr 17, 2016 IP
  12. Nigel Lew

    Nigel Lew Notable Member

    Messages:
    4,642
    Likes Received:
    405
    Best Answers:
    21
    Trophy Points:
    295
    #12

    Meh. Not in this case scenario.
     
    Nigel Lew, Apr 17, 2016 IP
  13. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #13
    NOTE: Please replace <http> with http:// in all the code and notes provided. As dp was not allowing example URLs, I had to put some pace holder.

    Problem:
    Sync the contents of multiple websites based on certain URL

    Assumptions:
    a) <http>ABC.com is your main website you want to update html content in the <body> tag and you want:
    b) <http>XYZ.com and <http>123.com to pull content of <body> tag from <http>ABC.com on certain page.
    c) Assuming <http>ABC.com, <http>XYZ.com and <http>123.com have one similar page that needs to be synced.
    d) <http>XYZ.com and <http>123.com will load the index.html body content that was updated on <http>ABC.com.


    Solution:
    a) create new file called sync.php and put following content:
    
    <?php
    if (isset($_GET['page']))
    {
          header('Content-Type: text/html');
          $html = file_get_contents(@$_GET['page']); //or use curl if this doesn't read
          if (!preg_match("/<body>(.*)<\/body>/Usi", $html, $matches))
              die('Body content not found at - '.$_GET['page']);
          die($matches[1]);
    }
    print 'Invalid request';
    
    Code (markup):
    b) upload file to root of sites need to synchronize , so the urls are <http>XYZ.com/sync.php and <http>123.com/sync.php

    c) test by opening url in browser <http>XYZ.com/sync.php?page=<http>ABC.com/index.html
    if it returns the same data as in the <body> tag of ABC.com index page, good, go ahead.

    d) At this point you need to modify you index.html file on each website that needs to keep same html as in ABC.com, that would be index.html in this case. Edit your XYZ.com/index.html and 123.com/index.html , remove all body tag content and put following code between their <body> and </body> tag. NOTE: Make sure to backup first : )
    
    <html>
    ........ whatever already here
    ........ keep it same
    <body>
    
           <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
           <script>
           jQuery(function(){
                jQuery.get('./sync.php?page=<http>ABC.com/index.html', function(body_html) {
                      jQuery('body').html(body_html);
                });
          });
          //not using $ for jQuery intentionally
      </script>
    
    </body>
    </html>
    
    Code (markup):

    Hope it helps (I did no test though). If there's any problem let me know.
    NOTE: this is one of many proposed solutions.

    Stay well..
     
    Vooler, May 13, 2016 IP
    Nigel Lew likes this.