5

I have a PHP page foo.php that pulls records from a MySQL database and displays them in a nice way. The tricky part is I have links at the top like "Sort by Name" that link to foo.php?sort=name.

My general question is if I have several POST variables like sort, there is an exponential number of possible pages (a few hundred in my case). Is there a good way to save all those pages for offline viewing? In the absence of a better solution I guess I can use a tool like wget to download all the possible combinations of the page. If this is the solution, can you recommend better tools for this task?

Edit: To answer the question of why I need this: I have a dynamic program for a conference ISPC 20 that I need to hand out to people on a usb flash drive. I don't think providing a WAMP solution is an option in this case.

Alan Turing
  • 12,223
  • 16
  • 74
  • 116
  • You could write a little script. Throw all the variables and their values into an array. Have some nested loops over all the variables and all their values to generate all the URLs. Use file_get_contents to download each URL and file_put_contents to write the result to a file. – Dan Grossman Jul 14 '11 at 20:33
  • 2
    What's the purpose of saving them offline? If it's so the user can use the app without being connected to the net, you would be better off creating a solution using a standalone W/LAMP stack – bcoughlan Jul 14 '11 at 20:35
  • Seconded @ having your own WAMP or LAMP stack. Pretty handy to have for a number of reasons and you won't have to specifically cater an application to achieving this for you. – MoarCodePlz Jul 14 '11 at 20:37
  • I added a description of what I need this for. A WAMP stack won't work in this case right? – Alan Turing Jul 14 '11 at 20:48

2 Answers2

3

Just ship a minimal webserver along with the PHP code. Much easier. Some options:

  • MicroApache can run off a 1.44Mb floppy
  • MoWeS is a small, modular webserver stack based off Apache, designed to run off an USB stick.
  • QuickPHP is a microserver usually used for testing. But it may suit your needs.
  • NanoWeb is written in PHP. Your clients will need PHP installed, but not a webserver.
  • PHP itself may in the future get a built-in webserver just like e.g. Python and Ruby have. Here's a patch that implements it.
Sander Marechal
  • 22,978
  • 13
  • 65
  • 96
  • Do you think so solutions can work if I have to make several hundred copies of the USB stick? In other words, can I install/configure **once** and then just copy? – Alan Turing Jul 14 '11 at 21:37
  • 2
    Sure. Just make it work off the stick, then use a cloning utility to clone the stick. That's by far the easiest way to create several hundred sticks. Even better because you can just give a dozen people a couple doizen sticks and the master image and say "Hey, get cloning!" – Sander Marechal Jul 14 '11 at 22:18
1

Can you implement the sorting (and/or other functionality) in JavaScript? If so, there's your problem solved.

There are a number of good libraries online for sorting tables in JS, including tablesorter. Check 'em out.

  • Interesting option. I'll think about it. The problem is besides sorting I am also doing other filtering variables such as the ability to click on a person and showing all the records associated with that person. – Alan Turing Jul 14 '11 at 21:43