Announcement

Collapse
No announcement yet.

Using variable declared in URL?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • thetakerfan
    replied
    well, the programming class is a joke, so it doesn't really matter. I only took it because I desperately needed an easy class in my schedule.

    Leave a comment:


  • JohnM
    replied
    I'm 13 and I learned PHP w/o any books... took me about 2 hours to read the manual on the basic stuff, and a couple days to get used to it...

    Leave a comment:


  • chrispadfield
    replied
    you are lucky. We never got taught to use a computer at all let alone programming (and i am only 19 so it was not long ago!).

    I always think it is hard to be taught to use a computer and especially to be taught to program somthing. Seems something you just have to learn yourself with the aid of books (or online manuals for the experts here )

    Leave a comment:


  • thetakerfan
    replied
    I'm learning vB in school, atleast thats what I signed up for anyway, damned public school system

    Leave a comment:


  • chrispadfield
    replied
    you guys are so great lol

    Leave a comment:


  • Freddie Bingham
    replied
    I didn't use no steenken book either (backwards redneck double-negative used on purpose)

    .. but it helps to know C

    Leave a comment:


  • thetakerfan
    replied
    I can not believe I didn't notice that

    Leave a comment:


  • JohnM
    replied
    I learned PHP w/o a book.. tho I am thinking about getting Professional PHP Programming...

    Leave a comment:


  • chrispadfield
    replied
    yesterday i started learning php. I started on a nice intro book "PHP Fast and Easy Web Development" before i get onto my Wrox press book. Guess what the exact page i am on is about.. you guessed it .. listing a directory

    Leave a comment:


  • JohnM
    replied
    oops!

    change this:
    Code:
    if ($file != "." && $file != ".." {
    to
    Code:
    if ($file != "." && $file != "..") {

    Leave a comment:


  • thetakerfan
    replied
    thanks for all your help so far John, I have it working except for one problem, the "." and ".." in the dir listing, I can't seem to get them to be removed, I get an error in that line of the file
    other than that, its working great

    Leave a comment:


  • JohnM
    replied
    Take a look at this:

    http://www.phpbuilder.com/manual/ref.dir.php

    here's basically what'd you'd want to do:

    Code:
    $dir = opendir("/path/to/dir/$name");
    echo "<h2>Directory listing for $name</h2>\n";
    echo "Files:<br>\n";
    while ($file = readdir($dir)) {
         if ($file != "." && $file != ".." {
              echo "<a href=\"/$name/$file\">$file</a><br>\n";
         }
    }
    closedir($dir);
    or you could do this:

    Code:
    $dir = dir("/path/to/dir/$name");
    echo "<h2>Directory listing for $name</h2>\n";
    echo "Files:<br>\n";
    while ($file = $dir->read()) {
         if ($file != "." && $file != ".." {
              echo "<a href=\"/$name/$file\">$file</a><br>\n";
         }
    }
    $dir->close();
    [Edited by JohnM on 10-21-2000 at 03:53 PM]

    Leave a comment:


  • thetakerfan
    replied
    I did not know that, thanks...but how would I be able to print a dir listing of "John", if the variable is "$name"?

    Leave a comment:


  • JohnM
    replied
    When something is passed via the querystring (?this=that), PHP automatically converts it to variables.

    For example, if you type "test.php?name=John", PHP would create a variable called $name with the value of John.

    Leave a comment:


  • thetakerfan
    started a topic Using variable declared in URL?

    Using variable declared in URL?

    How would I go about have a script do a couple different things based on a variable in the URL without specifying each variable within the script?
    ex)
    lyrics.php?fed=fedname would display a dir listing of everything in the "fedname" directory (preferably split into tables, but I didn't even look for that yet, so I'll try that later), and
    lyrics.php?fed=fedname&name=wrestlername would display the file "wrestlername" in the "fedname" directory.
    I don't know if this is possible at all, but I'd figure I'd ask, I looked through the php docs but didn't see anything
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X