Loading ...
Sorry, an error occurred while loading the content.

php sessions

Expand Messages
  • Rajesh Fowkar
    Hello, My code is as follows : if ( !isset($aGrnTypeDisplay[0]) ) { $oDempoConn = db_connect( dempo ); $sSql = select * from document_master where
    Message 1 of 2 , Jun 4, 2003
    • 0 Attachment
      Hello,

      My code is as follows :

      if ( !isset($aGrnTypeDisplay[0]) )
      {
      $oDempoConn = db_connect('dempo');
      $sSql = "select * from document_master
      where main_document_type_id = 'GRN' and
      company_code = '$sCompanyCode' and
      store_code = '$sStoreCode'
      order by document_description";
      $lResult = @pg_query($oDempoConn, $sSql);
      $nNumRows = @pg_num_rows($lResult);

      if ( $nNumRows <= 0 )
      {
      echo "<script language=javascript>
      alert('GRN Type not present in Document Master...');
      this.document.location.href='GUIMenus.php';
      </script>";
      }

      session_start();
      $_SESSION["aGrnTypeDisplay"] = array();
      $_SESSION["aGrnTypeValue"] = array();
      $_SESSION["nNumRowsGrnType"] = $nNumRows;
      for( $i=0; $i < $nNumRows; $i++)
      {
      $aAns = @pg_fetch_array($lResult, $i);
      $SubDocumentTypeId = $aAns['sub_document_type_id'];
      $TransactionIdentifier = $aAns['transaction_identifier'];
      $DocumentDescription = $aAns['document_description'];
      $JoinedValue = $SubDocumentTypeId . $TransactionIdentifier;
      $aGrnTypeDisplay[$i] = $DocumentDescription;
      $aGrnTypeValue[$i] = $JoinedValue;
      }
      session_write_close();
      |

      session_start();
      $aGrnTypeDisplay = $_SESSION["aGrnTypeDisplay"];
      $aGrnTypeValue = $_SESSION["aGrnTypeValue"];


      When I entered this form for the first time the array is created as
      session variable and filled with the values from the database. But when
      I tried to put it in a popup as follows:

      <TR>
      <TH>GRN Type:</TH>
      <TD>
      <SELECT NAME="cboGrnTypeAdd"
      <?
      echo "<option value=''><------Select------></option>";
      $nCnt = $_SESSION["nNumRowsGrnType"];
      for ( $nRow=0; $nRow < $nCnt; $nRow++ )
      {
      $sDescr = $aGrnTypeDisplay[$nRow];
      $nVal = $aGrnTypeValue[$nRow];
      if($nVal==$cboGrnTypeAdd)
      {
      echo "<option value='$nVal' selected>$sDescr</option>";
      }
      else
      {
      echo "<option value='$nVal'>$sDescr</option>";
      }
      }
      ?>
      </SELECT>
      </TD>
      </TR>

      What happens is for the first time the popup remains empty. When I load
      the page for the second time it shows all the values. What am I doing
      wrong in the above code ?


      Thanking you in advance.

      Peace

      --
      Rajesh
      :
      ####[ GNU/Linux One Stanza Tip (LOST) ]#######################

      Sub : Linux Tutorials LOST #071

      Looking for some LINUX TUTORIALS ? Check out this great book
      at sourceforge: http://rute.sourceforge.net/node19.html

      ####[jlambrec (at) landis.be]#################################
      :
    • Rajesh Fowkar
      ... Sorry for replying to my own mail. I was not assigning the actual array to the array of the session variable. $_SESSION[ aGrnTypeDisplay ] =
      Message 2 of 2 , Jun 4, 2003
      • 0 Attachment
        On Wed, Jun 04, 2003 at 02:32:37PM +0530, Rajesh Fowkar wrote:

        >Hello,
        >
        >My code is as follows :
        >
        >if ( !isset($aGrnTypeDisplay[0]) )
        >{
        > $oDempoConn = db_connect('dempo');
        > $sSql = "select * from document_master
        > where main_document_type_id = 'GRN' and
        > company_code = '$sCompanyCode' and
        > store_code = '$sStoreCode'
        > order by document_description";
        > $lResult = @pg_query($oDempoConn, $sSql);
        > $nNumRows = @pg_num_rows($lResult);
        >
        > if ( $nNumRows <= 0 )
        > {
        > echo "<script language=javascript>
        > alert('GRN Type not present in Document Master...');
        > this.document.location.href='GUIMenus.php';
        > </script>";
        > }
        >
        > session_start();
        > $_SESSION["aGrnTypeDisplay"] = array();
        > $_SESSION["aGrnTypeValue"] = array();
        > $_SESSION["nNumRowsGrnType"] = $nNumRows;
        > for( $i=0; $i < $nNumRows; $i++)
        > {
        > $aAns = @pg_fetch_array($lResult, $i);
        > $SubDocumentTypeId = $aAns['sub_document_type_id'];
        > $TransactionIdentifier = $aAns['transaction_identifier'];
        > $DocumentDescription = $aAns['document_description'];
        > $JoinedValue = $SubDocumentTypeId . $TransactionIdentifier;
        > $aGrnTypeDisplay[$i] = $DocumentDescription;
        > $aGrnTypeValue[$i] = $JoinedValue;
        > }


        Sorry for replying to my own mail. I was not assigning the actual array
        to the array of the session variable.

        $_SESSION["aGrnTypeDisplay"] = $aGrnTypeDisplay;
        $_SESSION["aGrnTypeValue"] = $aGrnTypeValue;

        In the above code (for loop) I tried using :

        $_SESSION["aGrnTypeDisplay[$i]"] = $DocumentDescription;
        $_SESSION["aGrnTypeValue[$i]"] = $JoinedValue;

        But this did not work, hence I resorted to the earlier method.

        Peace

        --
        Rajesh
        :
        ####[ GNU/Linux One Stanza Tip (LOST) ]#######################

        Sub : Command execution timing LOST #196

        To see how long it takes a command to run, type the word
        "time" before the command name. Try: #time updatedb

        ####[genesis (at) istar.ca]###################################
        :
      Your message has been successfully submitted and would be delivered to recipients shortly.