Jump to content

[SOLVED] Selecting a single field from a row and assign it to a variable?


clay1

Recommended Posts

I am having some difficulty wrapping my head around this.

 

I want to select a single value from a table for example:

 

pg_query($conn, "select email from markets where market = richmond");

 

I want to assign that to variable $email

 

pg_query gives me resource id #9

 

What do I need to do to get assign the email to the variable?

 

 

This is straight from the manual for pg_query

 

Example #1 pg_query() example

.

.

.

.

.

$result = pg_query($conn, "SELECT author, email FROM authors");
if (!$result) {
  echo "An error occured.\n";
  exit;
}

while ($row = pg_fetch_row($result)) {
  echo "Author: $row[0]  E-mail: $row[1]";
  echo "
\n";
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.