Jump to content


Photo

Change Values in a MySQL Array?


  • Please log in to reply
2 replies to this topic

#1 flyingeagle855

flyingeagle855
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 27 October 2006 - 02:03 AM

I am stuck on something here and need some help.
What I am looking to do is take and array of some values that I pulled from a MySQL database query and then I need to loop though the aray and look at CB.AVATAR for reach record and do an "if" statment to look at the value and then change the record if needed.

$query = "SELECT DISTINCT users.id, users.username, cb.avatar";
// Display Users Real Name Option
if ($display_realname != "0"){
	require_once($mosConfig_absolute_path . '/administrator/components/com_comprofiler/ue_config.php');
	if ($ueConfig['name_style'] == "1"){
		$query .= ", users.name";
	}elseif ($ueConfig['name_style'] == "2"){
		$query .= ", cb.firstname, cb.lastname";
	}elseif ($ueConfig['name_style'] == "3"){
		$query .= ", cb.firstname, cb.middlename, cb.lastname";
	}
}
if ($aboutme != "") {
	$query .= ", cb.". $aboutme." as aboutme";
}
$query .= ' FROM #__users as users, #__comprofiler as cb, #__session as session WHERE users.id = session.userid and users.id = cb.id';
$database->setQuery($query);
$rows = $database->loadObjectList();

Then latter in my code I push the array to patTemplate that automaticly goes through the array and iserts the fields I want to display.

#2 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 27 October 2006 - 02:21 AM

I don't recognize the database interface you are using.

Can you give us a sample of what var_dump($rows) looks like?  Or an example of how to access the result set?

#3 flyingeagle855

flyingeagle855
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 27 October 2006 - 01:43 PM

I probably should have explained that I am a developing a module for Joomla! CMS www.joomla.com thier site can explain better then I can about the database interface. Also the section on PatTemplate.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users