Thanks Tom,

I appreciate your help ! however I have a 2 quick questions...

1.) should we not save the names of the companies as $companies[$row] = $row['company'];
2.) the approach of accessing the variable as $details = $_SESSION['link']['$_GET['name']] is not
working , when I try to echo the $details is get something else. I am not sure how we use the
$_SESSION[ ] [ ] with 2 variables as shown.



any help will be appreciated.


regards
--Pushpinder


On Thursday, July 24, 2003, at 08:10 PM, Tom Rogers wrote:


Hi,

Friday, July 25, 2003, 7:13:27 AM, you wrote:
PSG> Hello All,

PSG> I am trying to create a small MySQL application using PHP. I have a
PSG> table of contacts with each record having over 30 fields. I have a
PSG> search page where a logged-in admin can search for a particular record
PSG> on the basis of certain parameters.


PSG> This is a sample code:


PSG> $sql1 = "SELECT * from `contacts` WHERE $where";


PSG> while ($row = mysql_fetch_array($result1)) {

PSG>          // Alternate the bgcolor of each row for visibility
PSG>              ($even % 2) == 0 ? $bgcolor = "#EFEFEF" : $bgcolor =
PSG> "#eeffff";
PSG>                  $even = $even + 1;

PSG> // print the actual row
PSG> echo "<TR BGCOLOR=$bgcolor>
PSG> <TD align=\"left\"><font color=\"#666666\" size=\"1\"
PSG> face=\"Verdana, Arial, Helvetica, sans-serif\">$row[company]</font></TD>
PSG> <TD align=\"left\"><font color=\"#666666\" size=\"1\"
PSG> face=\"Verdana, Arial, Helvetica, sans-serif\">$row[name_1]</font></TD>
PSG> <TD align=\"left\"><font color=\"#666666\" size=\"1\"
PSG> face=\"Verdana, Arial, Helvetica, sans-serif\">$row[phone_1]</font></TD>
PSG> <TD align=\"left\"><font color=\"#666666\" size=\"1\"
PSG> face=\"Verdana, Arial, Helvetica, sans-serif\">$row[city]</font></TD>
PSG> <TD align=\"left\"><font color=\"#666666\" size=\"1\"
PSG> face=\"Verdana, Arial, Helvetica, sans-serif\">$row[url]</font></TD>
PSG> <TD align=\"left\"><font color=\"#666666\" size=\"1\"
PSG> face=\"Verdana, Arial, Helvetica, sans-serif\">$row[email_1]</font></TD>
PSG> <TD align=\"center\"><font color=\"#333333\" size=\"1\"
PSG> face=\"Verdana, Arial, Helvetica, sans-serif\"><a
PSG> href=\"profile.php\">Link</a></font></TD>
PSG> </TR>";


PSG>          // try to register the variable
PSG>            $_SESSION['link'] = $row[company];
PSG>          } // end while
PSG>         // print the end of the table
PSG>            echo "</TABLE></body></html>";


PSG> The above tables displays the results of the query in a table form
PSG> with only the main fields of the record. The last column of the table
PSG> contains a link to view the full-contents of the record. when the user
PSG> clicks this link, he will go to another script called
PSG> "profile.php" which will display all the contents of the record. In
PSG> order to do this I will need to store all the primary keys (in this
PSG> case the name of the company) of each record from the result set and
PSG> then use it to retrieve all the contents. I have been successful in
PSG> trying to do this for a single row (record) of the result by
PSG> registering it as an session variable called ['link']



PSG> I am at a loss to figure out how to store the names of the first column
PSG> of the result set i.e. the company name. Is it possible to create an
PSG> array of the session variable ['link'] ?? Another approach would be
PSG> to get the names of the companies as a separate query and register them
PSG> as an array of session variables.



PSG> any suggestions will be welcome. Thanks in advance.


PSG> --Pushpinder

in the href put

...<a href=\"profile.php?name=".$row['name']."\">...

Make a seperate array as you loop

$companies[$row['name']] = $row;

in your session store it as

$_SESSION['link'] = $companies;

You can then access it in profile php as


$details = $_SESSION['link']['$_GET['name']]



-- regards, Tom


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to