473,326 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Zip Files, Mysql, Downloading, & PHP

Ajm113
161 100+
Hello, I created a database and all and have a php page that displays content to the readers when a certain id is entered in the address bar.

What I want to do is to have the user download a zip file that contains copies of that php script, but rename them to a title value of each row, so no replacing is done and display the individual content on each page from that title into the php pages that where made in the zip file.

How can I do this?
Sep 12 '08 #1
7 2026
nathj
938 Expert 512MB
Hi,

If I understand correctly you may want to take a look at the PHP Zip functions. These should help you create the zip file as you need it.

I've never done this myself so I can't offer any specific tips, however, if you get stuck I'm happy to look over any code and learn as I go.

Cheers
nathj
Sep 12 '08 #2
Ajm113
161 100+
I already looked over them before and their is no File Creation and Content Post in a programmed new file in a php zip file.

Now if I could create fake files of say page.php?id=C5435 TO /page/C5435.php and make the zip file upload thinking it is a actual page then I have something going so it will add a C5435.php file to the zip with the certain content in it so people could download the pages in one zip file.

Then I have something going, but I think this requires some Apache configuration.
Sep 12 '08 #3
nathj
938 Expert 512MB
Okay, well as I said before this is not something I've done myself.

If I could ask why you need this I may be able to get some more insight into what you are trying to achieve.

Cheers
nathj
Sep 12 '08 #4
Ajm113
161 100+
Have you ever seen something like 'Download' Wikipedia articles or PHP.net manual pages you can get in one click?

Its on their website, but just like my project I want to allow users to download my web pages in one click for offline purposes (Laptops) of my database in html format so you can take important information if you don't have internet access currently and it won't slow you down working on your project.
Sep 12 '08 #5
nathj
938 Expert 512MB
Have you ever seen something like 'Download' Wikipedia articles or PHP.net manual pages you can get in one click?

Its on their website, but just like my project I want to allow users to download my web pages in one click for offline purposes (Laptops) of my database in html format so you can take important information if you don't have internet access currently.

Okay, I think i understand the aim of the game. why is the speciofied format ZIP? Could you use the header functions and php echo statements to create a file that is then saved to the users machine> Here's a code sample of what I mean.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function __autoload($pcClassName)
  3. {    
  4.         require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/' . $pcClassName . '.php' ;
  5. }
  6. session_start();  
  7. $loDataObject    = new dataObject() ;    
  8. // Dates must be in the format YYYYMMDD    
  9. switch($_GET['type'])
  10. {
  11. case 1: // all future events
  12. $lcEventsSelect = "SELECT a.ID, a.title, a.summary, concat(date_format(a.startDate, '%Y%m%d'), 'T', date_format(a.startTime, '%H%i%S')) as start, concat(date_format(a.endDate, '%Y%m%d'), 'T', date_format(a.endTime, '%H%i%S')) as end, b.name as location FROM tbl_event a LEFT OUTER JOIN tbl_venue b on b.ID = a.venueID WHERE a.startDate>now() AND a.publishDate<=now() ORDER by startDate ASC" ;
  13. break;
  14. case 2: // all my bookings
  15. $lcEventsSelect = "SELECT a.ID, a.title, a.summary, concat(date_format(a.startDate, '%Y%m%d'), 'T', date_format(a.startTime, '%H%i%S')) as start, concat(date_format(a.endDate, '%Y%m%d'), 'T', date_format(a.endTime, '%H%i%S')) as end, b.name as location FROM tbl_event a LEFT OUTER JOIN tbl_venue b on b.ID = a.venueID WHERE a.startDate>now() AND a.publishDate<=now() AND a.ID IN (SELECT c.eventID FROM tbl_userevent c WHERE c.userID=$lnUserID) ORDER by startDate ASC" ;
  16. break;
  17. }
  18. $laEvent = $loDataObject->queryGetData(false,$lcEventsSelect);
  19. // Define the file as an iCalendar file
  20. header("Content-Type: text/Calendar");
  21. // Give the file a name and force download
  22. header("Content-Disposition: inline; filename=clocalendar.ics");
  23. // Header of ics file
  24. echo "BEGIN:VCALENDAR\n";
  25. echo "VERSION:2.0\n";
  26. echo "PRODID:PHP\n";
  27. echo "METHOD:REQUEST\n";
  28. // Loop through results and create an event for each item
  29. foreach($laEvent as $laEventRow)
  30. {
  31.     echo "BEGIN:VEVENT\n";
  32.     // The end date of an event is non-inclusive, so if the event is an all day event or one with no specific start and stop
  33.     // times, the end date would be the next day.  
  34.     echo "DTSTART:".$laEventRow['start']."\n";
  35.     echo "DTEND:".$laEventRow['end']."\n";
  36.     // Only create Description field if there is a description
  37.     if(isset($laEventRow['summary']) && $laEventRow['summary'] != '')
  38.     {
  39.             echo "DESCRIPTION:";
  40.             echo $laEventRow['summary']."\n";
  41.     }
  42.     if(isset($laEventRow['location']) && $laEventRow['location'] != '')
  43.     {
  44.             echo "LOCATION:";
  45.             echo $laEventRow['location']."\n";
  46.     }
  47.     echo "SUMMARY:{$laEventRow['title']}\n";
  48.     echo "UID:{$laEventRow['ID']}\n";
  49.     echo "SEQUENCE:0\n";
  50.     echo "DTSTAMP:".date('Ymd').'T'.date('His')."\n";
  51.     echo "END:VEVENT\n";
  52. }
  53. echo "END:VCALENDAR\n";
  54.  
What this does is create an iCal file based on my database and download it to the users machine. It does this when and only when they ask for it - via a link on the page.

Surely you could use something similar - each page has a link on it that fires up code like that above to generate, in your case, an HTML file. this could be one routine parameterised to handle retrieve any database content.

The obvious flaw with this is linked files - style sheets, images that sort of thing - which is presumably why you want to use a ZIP file - package everything up as a mini version of the site.

Couldn't you simply direct the user to their browsers capability for making the age available off line? Or provide a print style sheet so they can print it and take it away? I know if I want a page available off-line I print it using a PDF printer and then I have a PDF copy of it.

So, there's my latest ramblings on the matter, I'll continue to give it some thought - it's an interesting problem.

I'll post back if I come up with anything else.

Cheers
nathj
Sep 12 '08 #6
nathj
938 Expert 512MB
what about using this class Using this along with code to generate a file you could generate file on the fly, add it to the ZIP file, download the ZIP file and the delete the temporary file.

The code would need some loops and a possibly some directory creation depending on the code in the temporary file but it could just work.

I still think most users who want to take a page off line will know how in their browser.

Cheers
nathj
Sep 12 '08 #7
Ajm113
161 100+
Thanks, but I got tons of pages with notes and instructions on fixing errors.

So I need something for the user not wasting more time downloading the million pages and just instead download them in one click where they can get those pages individualy in a zip file, becuase the user won't know what he'll run into when he recives errors on a applications.

Thats the point of the website I am making, pretty much. I'll play with the code later today.
Sep 12 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fan of P2P | last post by:
Hi, Does anyone know how I can store files (mostly pictures) into a mySQL table? I have tried the load_file function but it seems to not work. i just get NULL as the value. Any examples...
1
by: Marc Hoeve | last post by:
Hello, I downloaded and installed the non-installer Windows version of MySQL tonight, but I can't find the .CNF files that I have to copy to the systemroot. Can anyone tell me where to find...
4
by: MLH | last post by:
A programmer developed an AMP (Apache/MySQL/PHP) application for me. When he was done, he sent me the PHP files and the MySQL dump file. Now, when I connect to the application on my LAN using...
2
by: Dave | last post by:
Dear Sirs, Is there a way to get the width and height of an image without downloading the image, or with just downloading a minimal portion of the image? For instance, I have a list of 10,000...
1
by: ktosiek | last post by:
hello how to upload files to mysql database thanks for help
1
by: Rahul Agarwal | last post by:
Hi We use few .xml and .xsl files in our web application and we found that these files even though fairly static gets downloaded to the client's machine everytime the page is refreshed. What...
0
by: just.starting | last post by:
I am having problem while downloading files from an apache server2.0.53 with php4.3.10.While downloading some files it generally stops after downloading some specific amount and then stops...
5
by: Barry | last post by:
Hi I am having trouble downloading documents saved in a blob. I get the correct data from the database. The original size saved in the table then equals the strlen of the file content...
4
by: yehaimanish | last post by:
I am developing the project management system. Each Project: 1. Title, description ... , stored in mysql database 2. Upto ten files (initial description), (name in db, file in file system) 3....
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.