Jump to content

[SOLVED] PHP ifram principle


justinede

Recommended Posts

Hello Freaks,

 

I am looking for code that will act like an iframe and put content from one of my pages into another. Kind of what wordpress does, they have index and they call in the header and footer and comments.

 

basically i have a website where i have last updated at the bottom and instead of going to all of my 10 pages and editing it over and over again, i want to have that info in just one file so i only have to edit it once. I could do this with an iframe, but i hate frames and i know you can do it in php so thanks in advance.

 

Justin

Link to comment
Share on other sites

my bad... missunderstood your question...

maybe I get it right this time then :P

 

you could make a file named "lastupdates.php" or w/e you want.. the just place <?php include("lastupdates.php"); ?> wherever you want it on your page...

 

if i missunderstood again, ima give up :P

Link to comment
Share on other sites

hehe no problemo :P .. havent slept for about 24 hours so it just took some time before my brain managed to process the question right xD

 

EDIT: In my own defense.. You can put the include() inside a <div> tag with "overflow:auto;" xD haha

Link to comment
Share on other sites

hahah same here. lol

 

ok so now I have to parts that are php included.. simple html and such..

what if i wanted to have like update.php and inside that, you would have two text boxes with the html from the two different included files.

 

 

basically so i can change stuff in one page.

Link to comment
Share on other sites

haha ok alright let me explain.

 

so suppose in my site, i have a recent news sidebar and a last updated div in my footer.

i got both of them in separate php files using your include code (<?php include("new.php"); ?>).

 

now instead of opening sidebar.php and updated.php to edit the content, i want to open up manage.php and be able to change the content in those to files from there.

 

understand me know? xD

Link to comment
Share on other sites

yeah now i get the question.. just ain't sure why u wanna do it like that xD

 

maybe you could try making separate textareas in manage.php loading the info from new.php and lastupdate.php

 

then you edit the content in the textareas and use fwrite or something?

 

not sure, but that would be my first guess ;)

Link to comment
Share on other sites

yo so i got this bit of code somewhat working. But, it has the content already filled in with $somecontent = "add this..."; I want it to be what ever i type in the textarea that i named somecontent. Also, i want it to read out the current file in the textbox and edit from there.

 

<?php
$filename = 'test.txt';
$somecontent = "Add this to the file\n";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

    // In our example we're opening $filename in append mode.
    // The file pointer is at the bottom of the file hence
    // that's where $somecontent will go when we fwrite() it.
    if (!$handle = fopen($filename, 'a')) {
         echo "Cannot open file ($filename)";
         exit;
    }

    // Write $somecontent to our opened file.
    if (fwrite($handle, $somecontent) === FALSE) {
        echo "Cannot write to file ($filename)";
        exit;
    }

    echo "Success, wrote ($somecontent) to file ($filename)";

    fclose($handle);

} else {
    echo "The file $filename is not writable";
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.