Array syntax

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

    Array syntax

    I have a problem with the syntax for arrays.

    First I define an array and assign 65 values to it from a mysql
    database. Using print_r (array_values($ arr_anmref)) I can see all the
    values and they are correct so no problem there.

    I then need to process the information from a form when the users
    clicks ok. (This is to update the records based on if the user has
    checked or unchecked a checkbox).

    When the user presses the OK button they are taken to a new page where
    I want to process the form and show the results of the processed
    information.

    However in the code I need to use the values from the array but its
    misfiring .

    The array is now empty and

    print_r (array_values($ arr_anmref))

    .....shows nothing

    I have tried adding session_start() at the top of both pages but to no
    avail.

    Any help greatly appreciated.

    Garry Jones
    Sweden

  • Andy Hassall

    #2
    Re: Array syntax

    On Sun, 08 Jul 2007 05:43:18 -0700, GarryJones <morack@algonet .sewrote:
    >First I define an array and assign 65 values to it from a mysql
    >database. Using print_r (array_values($ arr_anmref)) I can see all the
    >values and they are correct so no problem there.
    >
    >I then need to process the information from a form when the users
    >clicks ok. (This is to update the records based on if the user has
    >checked or unchecked a checkbox).
    >
    >When the user presses the OK button they are taken to a new page where
    >I want to process the form and show the results of the processed
    >information.
    >
    >However in the code I need to use the values from the array but its
    >misfiring .
    >
    >The array is now empty and
    >
    >print_r (array_values($ arr_anmref))
    >
    >....shows nothing
    >
    >I have tried adding session_start() at the top of both pages but to no
    >avail.
    Data only gets passed from page to page either by putting it in an HTML form
    that gets sent to the next page (or otherwise through query parameters in the
    URL) where it shows up in $_GET or $_POST, cookies ($_COOKIE), or through
    sessions.

    If you want to pass a value over the session, you have to put it in the
    $_SESSION array (after starting the session), and it'll then be available in
    $_SESSION on the next page.

    --
    Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
    http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

    Comment

    • ELINTPimp

      #3
      Re: Array syntax

      On Jul 8, 9:59 am, Andy Hassall <a...@andyh.co. ukwrote:
      On Sun, 08 Jul 2007 05:43:18 -0700, GarryJones <mor...@algonet .sewrote:
      First I define an array and assign 65 values to it from a mysql
      database. Using print_r (array_values($ arr_anmref)) I can see all the
      values and they are correct so no problem there.
      >
      I then need to process the information from a form when the users
      clicks ok. (This is to update the records based on if the user has
      checked or unchecked a checkbox).
      >
      When the user presses the OK button they are taken to a new page where
      I want to process the form and show the results of the processed
      information.
      >
      However in the code I need to use the values from the array but its
      misfiring .
      >
      The array is now empty and
      >
      print_r (array_values($ arr_anmref))
      >
      ....shows nothing
      >
      I have tried adding session_start() at the top of both pages but to no
      avail.
      >
      Data only gets passed from page to page either by putting it in an HTML form
      that gets sent to the next page (or otherwise through query parameters in the
      URL) where it shows up in $_GET or $_POST, cookies ($_COOKIE), or through
      sessions.
      >
      If you want to pass a value over the session, you have to put it in the
      $_SESSION array (after starting the session), and it'll then be available in
      $_SESSION on the next page.
      >
      --
      Andy Hassall :: a...@andyh.co.u k ::http://www.andyh.co.ukhttp://www.and....co.uk/space:: disk and FTP usage analysis tool
      Agreed, sessions is often the best method when you have to pass
      arrays. You can also use the serialize/unserialize to pass the array
      with the POST method.

      more information on how to accomplish the session method:
      PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


      and the serialize/unserialize method: http://us.php.net/serialize

      Steve

      Comment

      Working...