SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    i would like to ask is there a way to cut short the following url:

    http://www.mydomain.com/test.php?var1=2&var1=5&var1=3

    to

    http://www.mydomain.com/test.php?var1=3

    what i'm trying to do is.. when a user tricker an action on the page... the var1 is updated to a different value and so the url address... but if the user keep on changing the same variable... the url then display the same variable with different values again and again... what i want is the url address just display the last variable... as shows above

    could somebody please help... please excuse my english

  2. #2
    SitePoint Addict Chris Roane's Avatar
    Join Date
    Jul 1999
    Location
    Helena, MT
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I am assuming that you want specific content to appear, depending on what the value of the variable "var1" is. If that is true, then it should be easy to do. That doesn't mean that is the most efficient way of doing it though, but it would probably work.

    Hope this helps.

    Chris Roane

  3. #3
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Chris Roane
    Hi,

    I am assuming that you want specific content to appear, depending on what the value of the variable "var1" is. If that is true, then it should be easy to do. That doesn't mean that is the most efficient way of doing it though, but it would probably work.

    Hope this helps.

    Chris Roane
    yes... that's what i wanted to do... could you please tell me how to do it?

  4. #4
    SitePoint Addict Chris Roane's Avatar
    Join Date
    Jul 1999
    Location
    Helena, MT
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are several ways to do it, but I will explain the most understandable way.

    Here is the code that you can use for the main structure of the script.

    ------------------------
    <?
    If ($var1 == NUMBER) {

    // Content goes here

    } Else If ($var1 == NUMBER) {

    // Content goes here

    } Else If ($var1 == NUMBER) {

    // Content goes here

    ) Else If ($var1 == NUMBER) {

    // Content goes here

    }

    // Note you can use more else ifs, if you need too.
    ?>
    ------------------------

    You would replace the text "NUMBER" in each if statement, to read all the numbers that you will use. Then, for each number, you place the content that you want to appear if that number is specified, between that specific numbers' if statement. Here is an example piece of code that shows it in action:

    ------------------------
    <?
    If ($var1 == 1) {

    echo ("Var1 equals one.");

    } Else If ($var1 == 2) {

    echo ("Var1 equals two.");

    } Else If ($var1 == 3) {

    echo ("Var1 equals three.");

    ) Else If ($var1 == 4) {

    echo ("Var1 equals four.");

    }

    // Note you can use more else ifs, if you need too.
    ?>
    ------------------------

    You should keep in mind that using that method isn't the most efficient way of doing it, but it will work. If you have a lot of content that is inside those if statements, I suggest just creating seperate pages for each of the variables.

    Hope this helps.

    Chris Roane

  5. #5
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not quite sure what you mean, as in your example the value of var1 would be equal to 3 as it is the last value sent.

    So your two examples are in effect equal to each other.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  7. #7
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    we need to see the code you are using that generates the url as that is where your problem lies, if you post it we can see where it is going wrong.


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
  •