SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Oct 1999
    Location
    New York, NY
    Posts
    826
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using a ? in a URL

    I've noticed certain web sites incorporate a web address that uses a question mark towards the end of it for some reason. For example, something like http://www.mywebsite.com?sp=4

    I have a vague idea as to why they use it (something to do with tracking, right?!), but how can I, as a webmaster, incorporate the question mark usage into my pages?

    How can I learn about/take advantage of all its usages?

    Thanks.

    Josh

  2. #2
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Josh, using the ? indicates that you are passing variables from page to page. Those varibles can then be grabbed by a programming language on the linked page and performa actions on them. To give you an example from PHP.

    Let's say you wanted to "personalize" your pages with the users first name. YOu could ask for it in a FORM then pass it using a "query string" (the tech term for the ? and everything that follows it).

    They enter their name "Andy", then press enter. In the URL you will see something like this:

    www.biteme.com/nextpage.php?name=andy

    The variable is "name" and the value of "name" is andy. If you had a page equipped to process that variable, you could extract that value and use it to identify the user like so:

    <?php echo($name); ?>

    That would print the value of name (which in this case is andy). It's also possible to pass more than one name/value pair like so:

    http://www.biteme.com/nextpage.php?f...lname=matthews

    Fname stands for First Name and lname stands for...you got it, last name. You could then string those two together to get Andy Matthews using the same method as above.

    Does that make sense? You first have to be using some sort of programming language to be able to take advantage of this nifty feature.
    Last edited by creole; Jun 6, 2001 at 14:19.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  3. #3
    SitePoint Guru
    Join Date
    Oct 1999
    Location
    New York, NY
    Posts
    826
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Creole,

    Thanks for that lesson on using the question mark! It's all starting to make sense on how to use it (ex. personalizing pages with names) and I understand that in order to use in the first place, I'd need to be using some sort of programming language, but what other benefits are their for me to know of to see if it's even worth it to learn more!?!?

    Josh

  4. #4
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Everything "dynamic" about a site is set through whatever server side programming language you choose. You can set colours and templates (www.spawned.co.uk has skins through asp), you can do tutorial sets (www.studiococo.com has one showtut.asp and all tutorials are shown based on that), you can do message boards (newreply.php in this system handles the creation, posting, modifying and verification of new posts).

    Essentially, it allows you to go from straight html where whenever you want to make a change you need to change and reupload a page to something truly dynamic where you can add, edit and delete information on the fly from the internet (no uploading).

    Hope that helps a touch.

    Php isn't the only language out there, but it seems to be the preference of this community. ASP is also solid, CFM is a bit quirky but good and JSP is fast but weird to learn.
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  5. #5
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a great benefit to the query string can be found on one of my client sites:
    www.plusoneonline.com/pics

    You will see a listing of image galleries. When you rollover them look at the bottom of the screen. You will notice that the only thing that changes in the URL is the id=x. I am using a page called "display_thumbs.php3" as a "template" and I simply pass the ID of the gallery in question to the templage. It then pulls all content associated with that gallery from the database.

    Even better is the image itself. When you rollover one of the images in a gallery, you will see a gid=x&id=y. I have over 170 images on the site and previouslt I have a static HTML page for each one. What a pain! Now I use the SAME page to display each image just by giving the page (display.php3) the gallery id and the image id.

    Believe me, that is only the TIP of the iceberg. WHen I realized that I could save time and energy like this, I couldn't start learning programming and database fast enough.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •