| | |
generating txt using php
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
i have a problem in generating txt file from php. my prblem is After I add a news item etc. the script that updates the database would geneterate a text file. Then in my code instead of my 'include file show_news.php3' command, I would do a a include news.html that would be a pre-built html page. I think this would make the pages load faster. vs. making a bunch of mysql call each time a page is called. will u please help me
my problem is i wnat my site to be like this
http://www.daniweb.com/techtalkforums/thread32816.html
actually it is working on php but working as html
http://www.daniweb.com/techtalkforums/thread32816.html
actually it is working on php but working as html
I think the reason why people are not giving you answers is that it's not clear what your question is. We understand what you want to do, but we don't understand what you are having problems with.
Did we help you? Did we miss the point entirely? Update your thread and let us know.
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
ok i dont know how to do dynamic sites to static sites.
for example i have a real estate sites. the vistitors useses search engine to select resedential sites, he will get set of search list loction,type of land ext .and if person want to know details of that apartment he will click details.
this directs to details?listingid=26.php.
but i want details/26.html. i want in html but not php. i hope u have understood my problem
for example i have a real estate sites. the vistitors useses search engine to select resedential sites, he will get set of search list loction,type of land ext .and if person want to know details of that apartment he will click details.
this directs to details?listingid=26.php.
but i want details/26.html. i want in html but not php. i hope u have understood my problem
•
•
•
•
Originally Posted by aarya
i want in html but not php. i hope u have understood my problem
Ask questions. Seriously, we don't know what to help you with if we don't know what exactly it is that you don't know how to do.
If you don't know anything about how to make any parts of this program, then you are asking for a lot. I don't think anyone will design the entire project for you and then send you the source code.
If you are just hung up on some specifics, ask specific questions, such as: "How can I redirect out of a PHP script to another file on the site?"
Did we help you? Did we miss the point entirely? Update your thread and let us know.
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
aarya,
I would recommend that you purchase one of the following:
Professional LAMP
Beginning PHP, Apache, MySQL, Web Development
Core PHP Programming: Using PHP to Build Dynamic Web Sites
You seem to have quite a few questions, and this is a great place to start. However, you may want to take a more structured approach with this. That’s not meant to be offensive. It's just that one or more of these books may help bring you the structure you need as a novice, in this area, in a timely manner. You may find forums like this one more useful (a question here a question there that pops up, while you understand the underlying structure) after reading one of those books.
I would recommend that you purchase one of the following:
Professional LAMP
Beginning PHP, Apache, MySQL, Web Development
Core PHP Programming: Using PHP to Build Dynamic Web Sites
You seem to have quite a few questions, and this is a great place to start. However, you may want to take a more structured approach with this. That’s not meant to be offensive. It's just that one or more of these books may help bring you the structure you need as a novice, in this area, in a timely manner. You may find forums like this one more useful (a question here a question there that pops up, while you understand the underlying structure) after reading one of those books.
Hi aarya, :cheesy:
The question really is why you want to convert the php pages to static html files, and if it is necessary.
1) URL rewriting: The link you posted, though with an html extension, may actually be parsed by php. If this is the case, that means they are more concerned about Search Engine Friendly (SEF) urls than anything else.
2) PHP Cache: On the other hand they may very well be static html pages. If they are, then they may also be concerned about their server processing, and faster generation of the html page. (php will be slower to generate an html page).
In the case of this forum, (the link you posted above), it is most likely a SEF addon for VBulletin (this forum software) such as found here: http://www.vbulletin.org/forum/showthread.php?t=63314
If you're websites pages are very dynamic, like the real estate search listings page, you would probably want to use url rewriting (1).
Im not an expert, so I only know of the Apache Server methods of doing this.
You can rewrite the urls using mod_rewrite. Which is an apache module.
This is quite long to discuss here, but you can find alot of resources on the web.
Such as: http://www.sitepoint.com/article/sea...-friendly-urls
If your php page content does not change frequently, but you have alot of hits, and your server is slowing down, you can use a cache system (2).
A chache system, simple creates static html pages out of the php pages you have (but is more complicated then that).
Its discussed here: http://www.zend.com/zend/art/scriptcaching.php
What you can do is search the web for ready made open source scripts that do the job. They take care of a lot of problems that arise when you want to use these methods. (and automate alot of things, like changing all your links to point to the static files).
If you just want to know how to create an static html file from php, and are not concerned about the implementation. Its really simple:
[PHP]
// creates a local version of any url contents as html files
function cache_url($url, $cache_name, $cache_path = 'cache/') {
// this is simple the path to store the html file
$cache_abs_path = $cache_path.$cache_name;
// this opens an http connection to the url of your webpage
// search fopen at php.net
// you must supply a http path to this, so that we use the http wrapper and return only html
if (!$file = @fopen($url, 'r')) {
echo ('could not open the url: '.$url);
return false;
}
// this opens a file pointer to the html file you are saving too
// if the file doesnt exist, then it will attempt to create a new one
// you need the directory to have write permissions for the script
// chmod 777 (this can be done via ftp, or a web control panel, or php)
if (!$cache_file = @fopen($cache_abs_path, 'w+')) {
echo ('could not open the cache: '.$cache_abs_path.' for writing.');
return false;
}
// here we read the contents of the webpage
while($read = fread($file, '2082')) {
$content .= $read;
// we write the content of our webpage to the html file
if (!@fwrite($cache_file, $read)) {
echo ('error writing to cache: '.$cache_file.' for writing.');
return false;
}
}
// call the function like this
// here you will create a html page page_43.html in your pages directory.
// if you have the script in your webroot (http://mysite.com/) then the new page will be http://mysite.com/pages/page_43.html)
cache_url('http://mysite.com/page.php?id=43', 'page_43.html', 'pages');
[/PHP]
Good Luck.
www.digital-ether.com
The question really is why you want to convert the php pages to static html files, and if it is necessary.
1) URL rewriting: The link you posted, though with an html extension, may actually be parsed by php. If this is the case, that means they are more concerned about Search Engine Friendly (SEF) urls than anything else.
2) PHP Cache: On the other hand they may very well be static html pages. If they are, then they may also be concerned about their server processing, and faster generation of the html page. (php will be slower to generate an html page).
In the case of this forum, (the link you posted above), it is most likely a SEF addon for VBulletin (this forum software) such as found here: http://www.vbulletin.org/forum/showthread.php?t=63314
If you're websites pages are very dynamic, like the real estate search listings page, you would probably want to use url rewriting (1).
Im not an expert, so I only know of the Apache Server methods of doing this.
You can rewrite the urls using mod_rewrite. Which is an apache module.
This is quite long to discuss here, but you can find alot of resources on the web.
Such as: http://www.sitepoint.com/article/sea...-friendly-urls
If your php page content does not change frequently, but you have alot of hits, and your server is slowing down, you can use a cache system (2).
A chache system, simple creates static html pages out of the php pages you have (but is more complicated then that).
Its discussed here: http://www.zend.com/zend/art/scriptcaching.php
What you can do is search the web for ready made open source scripts that do the job. They take care of a lot of problems that arise when you want to use these methods. (and automate alot of things, like changing all your links to point to the static files).
If you just want to know how to create an static html file from php, and are not concerned about the implementation. Its really simple:
[PHP]
// creates a local version of any url contents as html files
function cache_url($url, $cache_name, $cache_path = 'cache/') {
// this is simple the path to store the html file
$cache_abs_path = $cache_path.$cache_name;
// this opens an http connection to the url of your webpage
// search fopen at php.net
// you must supply a http path to this, so that we use the http wrapper and return only html
if (!$file = @fopen($url, 'r')) {
echo ('could not open the url: '.$url);
return false;
}
// this opens a file pointer to the html file you are saving too
// if the file doesnt exist, then it will attempt to create a new one
// you need the directory to have write permissions for the script
// chmod 777 (this can be done via ftp, or a web control panel, or php)
if (!$cache_file = @fopen($cache_abs_path, 'w+')) {
echo ('could not open the cache: '.$cache_abs_path.' for writing.');
return false;
}
// here we read the contents of the webpage
while($read = fread($file, '2082')) {
$content .= $read;
// we write the content of our webpage to the html file
if (!@fwrite($cache_file, $read)) {
echo ('error writing to cache: '.$cache_file.' for writing.');
return false;
}
}
// call the function like this
// here you will create a html page page_43.html in your pages directory.
// if you have the script in your webroot (http://mysite.com/) then the new page will be http://mysite.com/pages/page_43.html)
cache_url('http://mysite.com/page.php?id=43', 'page_43.html', 'pages');
[/PHP]
Good Luck.
www.digital-ether.com
![]() |
Similar Threads
- Roating testimonials (text) in PHP (PHP)
- We've Gone PHP! (DaniWeb Community Feedback)
Other Threads in the PHP Forum
- Previous Thread: Capture text between tags
- Next Thread: storing details as html doc using php
| Thread Tools | Search this Thread |
.htaccess alexa apache api array beginner beneath binary broadband broken cakephp checkbox class cms code convert cron curl database date display dynamic echo email emptydisplayvalue encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image images include insert ip javascript joomla key keywords limit link login mail mail() memberships menu mlm multiple multipletables mysql mysql_real_escape_string network oop open passwords paypal pdf php provider query radio random redirect remote rss script search securephp server sessions smtp source space sql strip_tags syntax system table template tutorial update upload url user validator variable video voteup web youtube






