www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Question for Nog and others.

  1. #1
    Join Date
    Mar 2006
    Posts
    540

    Question for Nog and others.

    Hello Nog I hope you see this, or someone else who knows this answer please help. Anyone who has been around the block enough to have heard if this can be done. Does anyone know of a way with either php or javascript that something can create the web pages you want for you, and then uploads them to your site? At least something that creates the web pages, I can even upload them myself. What is happening is I am taking software programs and they come in so fast I can't keep up. It would be easier to have the pages made for me and then the ones I don't want I could just delete online. This making each page from scratch all the time is too much work and take up way too much time. Burnt out in web land.

    Please let me know if this can be done, I'll even hire someone if I have to. Thanks a whole lot.

  2. #2
    Join Date
    Mar 2006
    Posts
    540
    If it absolutely cannot be done with javascript and php if there is some sort of program available that will do this? Thank you.

  3. #3
    Join Date
    Mar 2006
    Posts
    540
    I found this link, this is exactly what I need. http://www.sitepoint.com/article/pub...mysql-data-web

    I am having trouble learning how to do the plug in. The thing that sends the mysql data put on the page, to the web server. I already know how to use php to put the mysql data on the page, I just don't know how to get it dynamically sent to the server.

  4. #4
    Join Date
    Mar 2006
    Posts
    540
    Someone sent me a private message who might be able to help, if they can't I'll let you all know.

  5. #5
    Join Date
    Mar 2006
    Posts
    540
    The last person wasn't able to help me with what I needed. According to the link I posted above, it says a php plug in can be made to take an updated web page and send it on somewhere to the server. Thats exactly what I need. This is basically what the article above says:

    "The PHP script outputs the mysql content as part of the Web page. (which I can do)

    A PHP plug-in finishes up by handing a copy of the HTML to the Web server. (which I don't know how to do)"

    I need help with the last above line. If anyone can help, please private message me. Or suggestions only that might help, please post here. Hope someone can help. Thanks very much.

  6. #6
    Join Date
    Jun 2007
    Posts
    348
    Do you mean that you want to know how to save the generated HTML as a separate, static HTML document? ...or, are you wanting to download (rather than merely display in the browser) the generated HTML document?

  7. #7
    Join Date
    Mar 2006
    Posts
    540
    Thanks so much for asking.

    The page is already appearing in the browser using a form, mysql, and php. Visitors are already adding their data to the page. So the answer is "how to save the generated HTML as a separate, static HTML document."

    I was hoping per example in above article that since I am already using php to do all the just listed above, that maybe an if statement, while the data is being put on the page, would also send the data and page onto the server in a directory anywhere.

    I thought since all the code is already written in php that just adding an if statement to the already there code would be the easiest way. But if someone can think of another way, that would be fine.

    I'm confused on something. If the page was then sent on to the server, wouldn't it just be back to its original state when the page was first opened in the browser without the data yet added?

    If so, how are people pulling their database info and generating pages automatically with it? I don't believe they are all doing this manually, many people have way to many web pages to do them all one at a time.

    Please get back to me, thanks.

  8. #8
    Join Date
    Jun 2007
    Posts
    348
    The first question to be answered is how to save the generated HTML as a separate, static HTML document. To do that, the easiest way is to turn on output buffering and point it to your function to create the static HTML document (that function can use the global statement to gain access to any variables in your page which may be required for the purpose of, for example, naming the saved document and pointing it to the correct folder):
    PHP Code:
    ob_start('save_html'); 
    Then, when you're done generating the HTML, execute the following function:
    PHP Code:
    ob_end_flush(); 
    So, the only part left is the function to save the generated HTML:
    PHP Code:
    function save_html($output)
    {
        global 
    $path_and_file_info;
    //
        
    $fp fopen($path_and_file_info'w');
        
    fwrite($fp$output);
        
    fclose($fp);
    //
        
    return $output;

    This function both writes the generated HTML to a file and returns the generated HTML to the output handler which, then, sends it on to the client.

  9. #9
    Join Date
    Mar 2006
    Posts
    540
    I can't send you a pm cause don't think you have it so I'll have to list it here. You seem to really know what your doing so I hope you'll let me find out if your approach will do what I need. Can you please explain to me what an output handler is? For the client I think your talking about the browser.

    Does this turn or copy everything into a web page? If so, how can I send it onto the server? Please get back to me, thank you very much.

  10. #10
    Join Date
    Jun 2007
    Posts
    348
    The output handler is outside of your code. It is what actually sends the output from your code to the client (the browser). Output buffering is a function of the output handler. Thus, it is the output handler which calls back your function when you request the output buffer to be flushed to the client. The output handler sends the content of the output buffer to your function as a single string argument. This gives your function the opportunity, if desired, to modify the output buffer before it actually gets sent to the client by the output handler. Once your callback function is done with the buffer the only thing your function has to do is return that buffer to the output handler for processing.

    The end effect of the code I've given you is that the generated HTML is both sent to the client and is saved as a static HTML document on the server.

  11. #11
    Join Date
    Mar 2006
    Posts
    540
    Are you serious? That sounds pretty exciting. Where will it send the document on the server, so I can find it to send it to other directories if needed? I would imagine it goes in one of your variables, but I can't tell which one.

  12. #12
    Join Date
    Jun 2007
    Posts
    348
    This statement:

    global $path_and_file_info;

    points to a normal variable you define anywhere in your page before you execute this statement:

    ob_end_flush();

    And the callback function has to be defined before you execute this statement:

    ob_start('save_html');
    Last edited by temp.user123; 07-08-2007 at 12:33 AM.

  13. #13
    Join Date
    Mar 2006
    Posts
    540
    The only thing I need to know is if it will save the whole web page to the server. It sounds like you are saying it will. Also if I set a server destination, but the same code is in the page, when it uploads a next page to the same location, it will keep replacing the one before. Unless you know of a way to add a number to the name of the each file in the code so each page has a slightly different name. That way it will just keep adding them all without overwriting anything. I would imagine that can be done. If you think all that checks out, I am very, very, interested can you help me finish it? Do you have an email? We can talk about payment then as well. Please let me know, thanks a lot.

  14. #14
    Join Date
    Jun 2007
    Posts
    348
    It will save everything you output between the:
    PHP Code:
    ob_start('save_html'); 
    and the:
    PHP Code:
    ob_end_flush(); 
    statements. If you want a different document name to be generated each time it is saved, then this is one way that could be accomplished:
    PHP Code:
    function save_html($output)
    {
        global 
    $path_and_file_info;
    //
        
    $suffix 0;
        while (
    file_exists($path_and_file_info))
        {
            
    $parts pathinfo($path_and_file_info);
            
    $path_and_file_info $parts['dirname'] .
                
    '/' basename($parts['basename'], '.'.$parts[extension]) .
                
    ' (' . (++$suffix) . ').' $parts[extension];
        }
    //
        
    $fp fopen($path_and_file_info'w');
        
    fwrite($fp$output);
        
    fclose($fp);
    //
        
    return $output;

    Last edited by temp.user123; 07-08-2007 at 01:23 PM.

  15. #15
    Join Date
    Mar 2006
    Posts
    540
    Thanks a lot, I've been reading up on this all day to see if I can learn what I'm doing. Looks like a whole new world. In the code you just listed is that a total call back or do I have to write separate for that? Only because what I have isn't working yet. It looks like you're saying, "while this page exists, send a copy of it to a particular directory." Let me know if I am reading that wrong. I put these here ob_start('/test.html'); and $parts['/uploadedfiles/']. From what I've read, it looks like I only need the directory path. Or do I need the full path? http://www.awebsite.com/ etc.
    Thanks very much.
    Last edited by Rianna; 07-09-2007 at 11:23 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles