how to fetch array values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • meeanji
    New Member
    • May 2008
    • 7

    how to fetch array values

    Dear friends,

    I am storing values in Array. My array looks like this::


    balu 26 MCA gold -------------> first row of array
    amar 27 MBA gold -------------> 2nd row of array
    raja 28 MSC gold -------------> 3rd row of array


    Now i would like to retrieve first row of array and its columns. I have to do in php.thanks in advance.suggest ions required.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Do you have any understanding of PHP?

    How is the array built?

    do a print_r() on your array and show us the results.

    Comment

    • meeanji
      New Member
      • May 2008
      • 7

      #3
      Originally posted by markusn00b
      Do you have any understanding of PHP?

      How is the array built?

      do a print_r() on your array and show us the results.
      Code:
      PHP code goes here
      while ($row = oci_fetch_array ($stmt1, OCI_BOTH)) 
      {
         $tempArray = array('ABC_BANK_ID' => $row['ABC_BANK_ID'],
      'ABC_BANKACCNT_STATUS' => $row['ABC_BANKACCNT_STATUS'],
      'ABC_BANK_BSB' => $row['ABC_BANK_BSB'],
      'ABC_BANK_ACCNAME' => $row['ABC_BANK_ACCNAME'],
      'ABC_BANK_ADDRESS1' => $row['ABC_BANK_ADDRESS1'],
      'ABC_BANK_ADDRESS2' => $row['ABC_BANK_ADDRESS2'],
       'ABC_BANK_SUBURB' => $row['ABC_BANK_SUBURB'],
      'ABC_BANK_ACCNUM' => $row['ABC_BANK_ACCNUM'],
      'ABC_BANK_ACCNAME1' => $row['ABC_BANK_ACCNAME1'],
      'ABC_BANK_ACCTYPE' => $row['ABC_BANK_ACCTYPE'],
      'ABC_STATE_ID' => $row['ABC_STATE_ID'],
      'ABC_BANK_NAME' => $row['ABC_BANK_NAME'],
      'ABC_BANK_SUFFIX' => $row['ABC_BANK_SUFFIX'],
      'ABC_ISO_COUNTRY_NUM_CODE' => $row['ABC_ISO_COUNTRY_NUM_CODE'],
      'ABC_ISO_CURRENCY_NUM_CODE' => $row['ABC_ISO_CURRENCY_NUM_CODE'],
      'ABC_MEMBER_ID' => $row['ABC_MEMBER_ID']
      array_push($result, $tempArray);
      I am doing Php from last 5 days. plz help me .
      Last edited by ronverdonk; May 22 '08, 03:50 PM. Reason: use code tags!!

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        You access the array using the key.

        The key is the first part of the array which is followed by the assignment:

        [php]
        $arr = array
        (
        'array_key1' => 'this is the first',
        'array_key2' => 'this is the second'
        );

        // access it by the array keys:
        echo $arr['array_key1'];
        [/php]
        Hope that helps.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          WARNING:
          Please enclose your posted code in [code] tags (See How to Ask a Question).

          This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

          Please use [code] tags in future.

          MODERATOR

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #6
            Originally posted by meeanji
            Code:
            PHP code goes here
            while ($row = oci_fetch_array ($stmt1, OCI_BOTH)) 
            {
               $tempArray = array('ABC_BANK_ID' => $row['ABC_BANK_ID'],
            'ABC_BANKACCNT_STATUS' => $row['ABC_BANKACCNT_STATUS'],
            'ABC_BANK_BSB' => $row['ABC_BANK_BSB'],
            'ABC_BANK_ACCNAME' => $row['ABC_BANK_ACCNAME'],
            'ABC_BANK_ADDRESS1' => $row['ABC_BANK_ADDRESS1'],
            'ABC_BANK_ADDRESS2' => $row['ABC_BANK_ADDRESS2'],
             'ABC_BANK_SUBURB' => $row['ABC_BANK_SUBURB'],
            'ABC_BANK_ACCNUM' => $row['ABC_BANK_ACCNUM'],
            'ABC_BANK_ACCNAME1' => $row['ABC_BANK_ACCNAME1'],
            'ABC_BANK_ACCTYPE' => $row['ABC_BANK_ACCTYPE'],
            'ABC_STATE_ID' => $row['ABC_STATE_ID'],
            'ABC_BANK_NAME' => $row['ABC_BANK_NAME'],
            'ABC_BANK_SUFFIX' => $row['ABC_BANK_SUFFIX'],
            'ABC_ISO_COUNTRY_NUM_CODE' => $row['ABC_ISO_COUNTRY_NUM_CODE'],
            'ABC_ISO_CURRENCY_NUM_CODE' => $row['ABC_ISO_CURRENCY_NUM_CODE'],
            'ABC_MEMBER_ID' => $row['ABC_MEMBER_ID']
            array_push($result, $tempArray);
            I am doing Php from last 5 days. plz help me .
            Ok. Looking past the obvious syntax errors..

            This is completely redundant.
            You are essentially just copying the array, element by element, and then doing nothing with it.

            You could just as well do:
            [code=php]
            while ($row = oci_fetch_array ($stmt1, OCI_BOTH))
            {
            $tempArray = $row;
            }
            [/code]

            What are you actually trying to accomplish?

            Comment

            Working...