Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
***I made a class called ContactData, and it looks like this:***Code: Select all
class ContactData
{
var $firstName;
var $lastName;
var $title;
function PutContactData($contactArray)
{
$this->firstName = $contactArray["firstName"];
$this->lastName = $contactArray["lastName"];
$this->title = $contactArray["title"];
}
}
***And then i have a database connection in another file that loads up an array with DB info and passes it to the PutContactData function. Like this:***
# Grab the Contact info for the given location
$tmp = $rowLocations["LocationID"];
$queryContacts = odbc_exec($odbc, "SELECT FirstName, LastName, Title FROM Contacts WHERE LocationID = $tmp") or die (odbc_errormsg());
while($rowContacts = odbc_fetch_array($queryContacts))
{
#Create empty class for contact data
$contactData = new ContactData();
# Store Contact Data in Class
$contactData->PutContactData($rowContacts);***and then in another file i try to display the info in the ContactData variables like this (the ContactData:***
Code: Select all
if (is_array ($contactData))
{
foreach ($contactData as $adata )
{
echo '<div class="container3">'.$adata->firstName.''.$adata->lastName.'('.$adata->title.')</div>';
}
}
else
{
echo '<div class="container3">No Contacts</div>';
}***none of the contacts get printed out to the screen....however i have a similar class (actually it's exactly the same with different names for functions and variables) that puts out locations but i don't have it in a foreach loop (because location is kind of like the parent to contact, so contacts needs to be looped within location) and it displays fine. does the class not like being renamed to $adata in the foreach loop?
any help is appreciated!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]