how to append variable to url which already has variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • PseudoMega

    how to append variable to url which already has variables

    I'm working with a PHP page I wrote which searches through records in a
    MySQL database.

    I have a <form method="post"wh ich currently passes all of search
    variables into the session array. I'd like to change the form to GET
    instead of POST so that all of the variables are in the URL.

    My problem is that I have already been using pagination code which
    creates links like <a href="?page=2"> . With all of the other variables
    in the session array, it works fine. But moving to the GET method, I
    need to append that "?page" variable to the existing URL with the other
    variables.

    I think I may have skipped over this chapter in all of my studies
    because I just have no idea how to pull it off :)

    Can anyone point me in the right direction?

  • Jerry Stuckle

    #2
    Re: how to append variable to url which already has variables

    PseudoMega wrote:
    I'm working with a PHP page I wrote which searches through records in a
    MySQL database.
    >
    I have a <form method="post"wh ich currently passes all of search
    variables into the session array. I'd like to change the form to GET
    instead of POST so that all of the variables are in the URL.
    >
    My problem is that I have already been using pagination code which
    creates links like <a href="?page=2"> . With all of the other variables
    in the session array, it works fine. But moving to the GET method, I
    need to append that "?page" variable to the existing URL with the other
    variables.
    >
    I think I may have skipped over this chapter in all of my studies
    because I just have no idea how to pull it off :)
    >
    Can anyone point me in the right direction?
    >
    This is html. not PHP. Try alt.html.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Philip Serefoglou

      #3
      Re: how to append variable to url which already has variables

      keep the form to post but add to action atribute the get part you
      require for the pagging stuff.

      <form method="POST" action="myform. php?page=123">

      It will submit post stuff through post method in the script wich will be
      invoked by get vars :)


      ----- Original Message -----
      From: "PseudoMega " <pseudomega@gma il.com>
      Newsgroups: comp.lang.php
      Sent: Tuesday, December 19, 2006 5:08 AM
      Subject: how to append variable to url which already has variables

      I'm working with a PHP page I wrote which searches through records in a
      MySQL database.
      >
      I have a <form method="post"wh ich currently passes all of search
      variables into the session array. I'd like to change the form to GET
      instead of POST so that all of the variables are in the URL.
      >
      My problem is that I have already been using pagination code which
      creates links like <a href="?page=2"> . With all of the other variables
      in the session array, it works fine. But moving to the GET method, I
      need to append that "?page" variable to the existing URL with the other
      variables.
      >
      I think I may have skipped over this chapter in all of my studies
      because I just have no idea how to pull it off :)
      >
      Can anyone point me in the right direction?
      >

      Comment

      • punkstar

        #4
        Re: how to append variable to url which already has variables

        You want to make php generate a hidden field in your form like:

        <input type="hidden" name="page" value="<?=$_GET['page'];?>" />

        That should solve it, unless I have just totally misread your question,
        in which case.. please explain a little clearer :)

        Nick

        Jerry Stuckle wrote:
        PseudoMega wrote:
        I'm working with a PHP page I wrote which searches through records in a
        MySQL database.

        I have a <form method="post"wh ich currently passes all of search
        variables into the session array. I'd like to change the form to GET
        instead of POST so that all of the variables are in the URL.

        My problem is that I have already been using pagination code which
        creates links like <a href="?page=2"> . With all of the other variables
        in the session array, it works fine. But moving to the GET method, I
        need to append that "?page" variable to the existing URL with the other
        variables.

        I think I may have skipped over this chapter in all of my studies
        because I just have no idea how to pull it off :)

        Can anyone point me in the right direction?
        >
        This is html. not PHP. Try alt.html.
        >
        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        Working...