0
$agent_query=mysql_query("
                            SELECT name FROM users WHERE id='$agent_id'
                        ");
$get_agent_name=mysql_fetch_assoc($agent_query);            
$this->session->agent=$get_agent_name['name'];

I know the mysql_fetch_assoc() expects parameter 1 to be resource, but is there a way I can get just the name without running any loop in Zend?

Dharman
  • 30,962
  • 25
  • 85
  • 135
newbie
  • 1,023
  • 20
  • 46

1 Answers1

0

The php function mysql_result can be used to return a single field for a query by specifying the row and column you want returned. As there is only 1 row and column for your query (I assume), they will always be 0 and 0.

$name = mysql_result($agent_query, 0, 0);
Brenton Alker
  • 8,947
  • 3
  • 36
  • 37