Vernard
Vernard

Reputation: 477

How to display php file output inside a html div?

Alright, so I'm trying to embed a php script that outputs a gallery of images onto my html div container. However, after an hour or so of searching I'm coming up clueless.

http://craftedbyfrank.com/test/instagram.php

That's the link to the php gallery script.

I want to display it onto the main page inside that div. [REMOVED] - thanks!

I've tried the following, but I believe it's just wrong. I get no output.

 <div id="container">
 <?php include "instagram.php"; ?>
 </div>

I'm trying to avoid actually pasting the php script into the html file.

Upvotes: 0

Views: 16649

Answers (3)

Boris
Boris

Reputation: 802

As @vletech suggested you can use AJAX to get the result from the php file.

However the main reason why it does not work is because you are trying to execute the php script inside an .html file: e.g. your page loads on - /test/index.html. In order to work the file has to be with a .php extension.

Upvotes: 1

Rob
Rob

Reputation: 12872

php is not being parsed on your server. If you view the html source you see the actual php code you are using to include the file. Make sure that php is installed or you're not embedding the php from a cms that's encoding your tags.

Upvotes: 3

dev
dev

Reputation: 4009

You could possibly use AJAX to get the result from the PHP file and write to the containing div.

$.ajax({
    type:'GET',
    url:'http://craftedbyfrank.com/test/instagram.php',
    data:'',
    success: function(data){
            $('#container').html(data);
    }
});

You would possible need to adjust to get your fancy box plugin to work.

Upvotes: 1

Related Questions