Forum Moderators: coopster

Message Too Old, No Replies

One page to display many things

why write many pages when 1 will do

         

ITEagle03

5:36 am on Feb 11, 2003 (gmt 0)

10+ Year Member



I'm fairly new to PHP, but I have some experience with html and ASP...

I want to make a page that will insert simple text (or perhaps html) into a page. The file inserted depends on the prior link clicked (which means data must be passed). Here's the page I'm trying pass data from www.mysite.ws/codeex.php to display.php. If you look at the one link on the codeex.php, I'm currently trying to get it to pass data.

Tips are more then welcome. :)

[edited by: jatar_k at 6:05 am (utc) on Feb. 11, 2003]
[edit reason] no urls please [/edit]

jatar_k

6:09 am on Feb 11, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld ITEagle03,

why not try a get string

www.mysite.ws/display.php?page=1

and then get it through

$_GET['page']

dingman

5:06 pm on Feb 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Another technique I've used is to check the contents of $_SERVER['PHP_SELF'] and use that to decide what content to display. Then the rest of my pages are symlinks to a single PHP script. It's probably only a good idea for relatively small sites, but for those it's an easy way to avoid both query-strings and learning mod_rewrite. (Something that's still on my "todo" list, but not very high at the moment.)

andreasfriedrich

5:27 pm on Feb 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thatīs a nice idea to avoid mod_rewrite [httpd.apache.org] Andrew :).

dingman

5:41 pm on Feb 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks.

It's probably worth noting that symlinks and $_SERVER['PHP_SELF'] is only good for situations where you know ahead of time what all the valid values for your variables are, and there are few enough of them that you can set up all the right symlinks easily. It really wouldn't scale well. I don't think I'd even reccoment it for two variables, let alone more.

I can think of ways to work around these limitations, too, but they all get sufficiently Bizantine that you might as well just learn mod_rewrite.

andreasfriedrich

6:02 pm on Feb 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sure, mod_rewrite [httpd.apache.org] is more flexible, but itīs still nice to know of other ways to avoid query strings when for whatever reasons mod_rewrite [httpd.apache.org] just isnīt an option. And even if you donīt use it for that, itīs still smart thinking and thatīs what I like about it :).

As for the not scaling well part there is always a shell/perl/php script that could create those for you. But I guess those were the Bizantine ways that you mentioned ;)

Andreas

ITEagle03

7:52 am on Feb 12, 2003 (gmt 0)

10+ Year Member



Ok, I got it to pass the variables from page to page, but I've run into another problem. I have an:
include($filename) which worked fine for small files, but it chokes on larger files (one that I want to insert is something like 800k). What's another way to insert a (large) file? Perhaps use the printf() function? If that's possible, what's the syntax one would use to print a large file?

Thanks.