generating txt using php

Reply

Join Date: Sep 2005
Posts: 139
Reputation: aarya is an unknown quantity at this point 
Solved Threads: 0
aarya's Avatar
aarya aarya is offline Offline
Junior Poster

generating txt using php

 
0
  #1
Sep 23rd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 139
Reputation: aarya is an unknown quantity at this point 
Solved Threads: 0
aarya's Avatar
aarya aarya is offline Offline
Junior Poster

Re: generating txt using php

 
0
  #2
Sep 23rd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 902
Reputation: chrisbliss18 is an unknown quantity at this point 
Solved Threads: 23
chrisbliss18's Avatar
chrisbliss18 chrisbliss18 is offline Offline
Posting Shark

Re: generating txt using php

 
0
  #3
Sep 23rd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 139
Reputation: aarya is an unknown quantity at this point 
Solved Threads: 0
aarya's Avatar
aarya aarya is offline Offline
Junior Poster

Re: generating txt using php

 
0
  #4
Sep 24th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 22
Reputation: ashwinperti is an unknown quantity at this point 
Solved Threads: 0
ashwinperti ashwinperti is offline Offline
Newbie Poster

Re: generating txt using php

 
0
  #5
Sep 24th, 2005
it can be like this
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 902
Reputation: chrisbliss18 is an unknown quantity at this point 
Solved Threads: 23
chrisbliss18's Avatar
chrisbliss18 chrisbliss18 is offline Offline
Posting Shark

Re: generating txt using php

 
0
  #6
Sep 24th, 2005
Originally Posted by aarya
i want in html but not php. i hope u have understood my problem
Once again. I understand what you are wanting to do, didn't ask any questions. I have actually built a site exactly like this many times (using Perl and MySQL) but didn't redirect to static pages. Redirecting to an html file rather than a php script isn't hard, but I think you are having more problems than just figuring out the redirect. Also, realize that the pages on this forum are not static files; rather, they are most likely html files with embedded PHP that the server parses before returning the file.

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
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 93
Reputation: fsn812 is an unknown quantity at this point 
Solved Threads: 1
fsn812's Avatar
fsn812 fsn812 is offline Offline
Junior Poster in Training

Re: generating txt using php

 
0
  #7
Sep 24th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,073
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: generating txt using php

 
0
  #8
Sep 27th, 2005
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC