php mysql form variable works one time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • baccaril@gmail.com

    #1

    php mysql form variable works one time

    Hello,

    I have a form the post to a php script, the variable is passed to the
    php script successfully. I then query MySQL and output 8 rows at a
    time. So the problem I'm having is the first 8 rows are displayed on
    the web page correctly, but now when I attempt to display rows 9-16
    the variable that was posted from the form is now blank. How do I
    ensure the variable does not disappear?

    LouB.

    =============== =============== ===
    Here are the three main part of my php script.


    # post from form....
    $sortby = $_REQUEST["sortby"];

    $query = "select personal_identi fier, first_name, last_name,
    company_name, photo_path, custom_field_1 from $dbname order by $sortby
    limit $offset, $rowsPerPage";

    result = mysql_query ($query)
    //or die ("Cannot execute query");
    or die (mysql_error()) ;

  • BKDotCom

    #2
    Re: php mysql form variable works one time


    baccaril@gmail. com wrote:
    Hello,
    >
    I have a form the post to a php script, the variable is passed to the
    php script successfully. I then query MySQL and output 8 rows at a
    time. So the problem I'm having is the first 8 rows are displayed on
    the web page correctly, but now when I attempt to display rows 9-16
    the variable that was posted from the form is now blank. How do I
    ensure the variable does not disappear?
    >
    LouB.
    something tells me you have a "click here to see rows 9-16" type link?
    are you passing you var in the link?

    Comment

    • baccaril@gmail.com

      #3
      Re: php mysql form variable works one time

      Yes I have links printed at the end of the first page for viewing
      additional rows/page.
      I did not believe I need to pass the vaiable. If needed how do I do
      that?

      Lou

      Here is the code for links at end og page.
      =============== =============== =============== ===============
      #
      # print number of pages available at bottom of the web page

      // how many rows we have in database
      $query = "SELECT COUNT(*) AS numrows FROM $dbname";
      $result = mysql_query($qu ery) or die('Error, query failed');
      $row = mysql_fetch_arr ay($result, MYSQL_ASSOC);

      $numrows = $row['numrows'];

      // how many pages we have when using paging?
      $maxPage = ceil($numrows/$rowsPerPage);

      // print the link to access each page
      $self = $_SERVER['PHP_SELF'];
      $nav = '';

      for($page = 1; $page <= $maxPage; $page++)
      {
      if ($page == $pageNum)
      {
      $nav .= " $page "; // no need to create a link to current page
      }
      else
      {
      $nav .= " <a href=\"$self?pa ge=$page\">$pag e</a";
      }
      }

      print "$nav";

      =============== =============== =============== ========

      baccaril@gmail. com wrote:
      Hello,
      >
      I have a form the post to a php script, the variable is passed to the
      php script successfully. I then query MySQL and output 8 rows at a
      time. So the problem I'm having is the first 8 rows are displayed on
      the web page correctly, but now when I attempt to display rows 9-16
      the variable that was posted from the form is now blank. How do I
      ensure the variable does not disappear?
      >
      LouB.
      >
      =============== =============== ===
      Here are the three main part of my php script.
      >
      >
      # post from form....
      $sortby = $_REQUEST["sortby"];
      >
      $query = "select personal_identi fier, first_name, last_name,
      company_name, photo_path, custom_field_1 from $dbname order by $sortby
      limit $offset, $rowsPerPage";
      >
      result = mysql_query ($query)
      //or die ("Cannot execute query");
      or die (mysql_error()) ;

      Comment

      • baccaril@gmail.com

        #4
        Re: php mysql form variable works one time

        Thanks for the help. It was a issue where I was not passing the
        secound var in the link. I corrected the problem with the following:

        $nav .= " <a href=\"$self?pa ge=$page&sortby 1=$sortby\">$pa ge</a";

        BKDotCom wrote:
        baccaril@gmail. com wrote:
        Hello,

        I have a form the post to a php script, the variable is passed to the
        php script successfully. I then query MySQL and output 8 rows at a
        time. So the problem I'm having is the first 8 rows are displayed on
        the web page correctly, but now when I attempt to display rows 9-16
        the variable that was posted from the form is now blank. How do I
        ensure the variable does not disappear?

        LouB.
        >
        something tells me you have a "click here to see rows 9-16" type link?
        are you passing you var in the link?

        Comment

        • SquishedOrange

          #5
          Re: php mysql form variable works one time

          Thats very insecure script.

          Have a look at: mysql_real_esca pe(), is_number(), isset()

          Comment

          Working...