Avatar of Bruce Gust
Bruce Gust
Flag for United States of America

asked on 

How do I retrieve the individual results of an array?

Here's my function:

public function pref_reference() {

	global $mysqli;

	$sql="select preferences.email, preferences.id as pref_id, preferences.tool_id, preferences.tool_fields, tools.tool_name, tools.id from preferences inner join tools on preferences.tool_id=tools.id where preferences.id='$_GET[id]'";
			.'ERRNO: '
			.' QUERY: '
			trigger_error($err, E_USER_WARNING);

	return $result_array;

Open in new window

I want to retrieve from this array the email address and the tool id.

So, I've got this:

$new_tool = new ToolAdmin; //call my class

$reference=$new_tool->pref_reference(); // call the above method

Now I want to echo just the email address that's a part of this array. I've tried:

$reference['email_address'], $reference[0] and just about any other combo I can think of. I know I'm missing something, but I can't figure out what.

I know how to do a foreach, but is there a more direct way of just being able to reference specific values within the array?

Avatar of undefined
Last Comment
Bruce Gust

8/22/2022 - Mon