Passing Values between Pages : $_SESSION / $_GET

From: Date: Fri, 08 Aug 2003 15:46:49 +0000
Subject: Passing Values between Pages : $_SESSION / $_GET
Groups: php.general 
Request: Send a blank email to php-general+get-158865@lists.php.net to get a copy of this message
Hello All, I am using php and mysql in my application which allows users to search/query a database. The database is cast and has about 32 rows per record. When the user fires the query, the result is in the form of a table that contains only the 6 important rows of the entire record. Also there is a provision to allow the user to see the full record set by clicking on the link under the 'complete profile' contained in the table. (as shown below). The name of this script is lookup_results.php Here is the result for a companies in city = 'Charlotte' / Primary key of the table is the name of the company. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Company Name     Main Contact        City                 Website                                 E-Mail                          Complete Profile
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PSG                           Pushpy              Charlotte         http://www.psg.com        psgarcha@psg.com                --Link--
TFNA                         Napier               Charlotte         http://www.psg.com        psgarcha@psg.com                --Link--
Micro                         Bates                 Charlotte          http://www.psg.com       psgarcha@psg.com                --Link--
CNN                          Garcha PS        Charlotte          http://www.psg.com       psgarcha@psg.com                --Link--
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
To see the complete profile of the company I use href=\"full_profile_1.php?name=".$row['company']. So once we are on the full_profile_1.php, we can see all the contents of the record. Also we display a form where we can edit the results in place. The logic works like this. // full_profile_1.php LOGIC <? session_start(); if (isset($_SESSION['validuser'])) {
    if($submit)
      {
               update the changes that the user has made to the form
          My question here is  " How do I get the name of the company that was passed to this script as a $_GET Parameter. I cannot use the
          $company because it is out of scope. The only other option would be to use $_SESSION['link'] .... i.e. Store the names of the
          companies in a  session array. So now the array as per the example above would be {'PSG','TFNA', 'Micro', 'CNN' } . The way this
          will work is how do I get the index of the 'link' array that is applicable in this example.
           Here the name of the company would be $company  = $_SESSION['link'][0];
           If we had clicked the second row of the results table the name of the compnay would have been 'TFNA' i.e. $_SESSION['link'][1]
           and so on. How do I pass the index. ???
      }
else
      {
          $company = $_GET['name'];
      USE  <form name="form1" method="post" action="full_profile_1.php">
     AND    display all the rows of the record where company_name ='company'
     }
} else {
     redirect the user to the ERROR Page
} // end of pseudo- code Thanks in advance guys. I know this may sound a lil' vague , but I have tried to present the logic and the problem.

« previous php.general (#158865) next »