Help With Passing Data To/From Class

From: Date: Fri, 22 Dec 2000 17:08:43 +0000
Subject: Help With Passing Data To/From Class
Groups: php.general 
Request: Send a blank email to php-general+get-31597@lists.php.net to get a copy of this message
I'm new to OOP and hope I'm doing this right. I've got a class that handles info/functions about "people" - ex. their name. In my HTML page I have the following: ------------------ $select_people = new people; $search_results = array(); $search_results = $select_people->select_person_by_lname ($view, $sort, $order); ------------------ In the class, I have the following function: ------------------ function select_person_by_lname ($view, $sort, $order) { $query = "SELECT id FROM people WHERE last_name like '$view%' ORDER BY $sort $order"; $db = new db_sql; $db->query($query); $select_person_by_lname_array = array (); $num_results = $db->number_rows (); if ($num_results > 0) { $this->valid = "Y"; } else { $this->valid = "N"; } $i = 0; while ($db->next_record ()) { $select_person_by_lname_array[$i] = $db->Record["id"]; $i ++; } return ($select_person_by_lname_array); } ------------------ Here is the problem: 1. $search_results in the HTML page is empty, so it seems that the array I'm passing back from the function/class is not going through properly. 2. This line from the class: "if ($num_results > 0) { $this->valid = "Y"; } else { $this->valid = "N"; }" in the class does not seem to work. $this->valid is empty. There are results returned from the query... I have verified that, but I can't seem to assign a value to that variable. I have a feeling I'm just not doing something right, or not thinking about objects properly. Any help would be greatly appreciated. Thanks very much. -- Clarence Kwei ckwei@sciencentral.com ScienCentral, Inc. (212) 244-9577 ext. 118 <http://www.sciencentral.com> <http://www.stn2.com>

« previous php.general (#31597) next »