/    Sign up×
Community /Pin to ProfileBookmark

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.

to post a comment
PHP

15 Comments(s)

Copy linkTweet thisAlerts:
@RiannaauthorJul 07.2007 — If it absolutely cannot be done with javascript and php if there is some sort of program available that will do this? Thank you.
Copy linkTweet thisAlerts:
@RiannaauthorJul 07.2007 — I found this link, this is exactly what I need. http://www.sitepoint.com/article/publishing-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.
Copy linkTweet thisAlerts:
@RiannaauthorJul 07.2007 — Someone sent me a private message who might be able to help, if they can't I'll let you all know.
Copy linkTweet thisAlerts:
@RiannaauthorJul 08.2007 — 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.
Copy linkTweet thisAlerts:
@temp_user123Jul 08.2007 — 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?
Copy linkTweet thisAlerts:
@RiannaauthorJul 08.2007 — 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.
Copy linkTweet thisAlerts:
@temp_user123Jul 08.2007 — 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 [B]global[/B] 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):
[code=php]
ob_start('save_html');[/code]

Then, when you're done generating the HTML, execute the following function:
[code=php]
ob_end_flush();[/code]

So, the only part left is the function to save the generated HTML:
[code=php]
function save_html($output)
{
global $path_and_file_info;
//
$fp = fopen($path_and_file_info, 'w');
fwrite($fp, $output);
fclose($fp);
//
return $output;
}[/code]

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.
Copy linkTweet thisAlerts:
@RiannaauthorJul 08.2007 — 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.
Copy linkTweet thisAlerts:
@temp_user123Jul 08.2007 — 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 [I][U]both[/U][/I] sent to the client [I][U]and[/U][/I] is saved as a static HTML document on the server.
Copy linkTweet thisAlerts:
@RiannaauthorJul 08.2007 — 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.
Copy linkTweet thisAlerts:
@temp_user123Jul 08.2007 — 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');
Copy linkTweet thisAlerts:
@RiannaauthorJul 08.2007 — 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.
Copy linkTweet thisAlerts:
@temp_user123Jul 08.2007 — It will save everything you output between the:
[code=php]
ob_start('save_html');[/code]

and the:
[code=php]
ob_end_flush();[/code]

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:
[code=php]
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;
}[/code]
Copy linkTweet thisAlerts:
@RiannaauthorJul 10.2007 — 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.
Copy linkTweet thisAlerts:
@temp_user123Jul 10.2007 — It's all there. You will even know the generate file name after that callback function has executed. The callback function stores the generated file name back into the global variable for your use -- if needed. None of the code in this function should be changed. You just set the [B]$path_and_file_info[/B] variable outside of this code somewhere.

Here, I've added some comments:
[code=php]
function save_html($output)
{
global $path_and_file_info; // global file name variable
// if file already exists, create a generation of that name
$file = $path_and_file_info; // temporary storage for generated name
$parts = pathinfo($file); // extract parts of temporary file name
$suffix = 0;
while (file_exists($file)) // while the generated file exists
{
$file = $parts['dirname'] .
'/' . basename($parts['basename'], '.'.$parts[extension]) .
' (' . (++$suffix) . ').' . $parts[extension]; // add new generation suffix
}
$path_and_file_info = $file; // place generated name back into global storage
// save the generated client stream to a file on the server
$fp = fopen($path_and_file_info, 'w'); // open global file name
fwrite($fp, $output); // write client stream to file
fclose($fp); // close file
//
return $output; // return client stream to output handler
}[/code]
×

Success!

Help @Rianna spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...