From: | "Matthias Ritzkowski" <matthiar(at)gmail(dot)com> |
---|---|
To: | PJ <af(dot)gourmet(at)videotron(dot)ca> |
Cc: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: display query results |
Date: | 2008-07-30 16:35:34 |
Message-ID: | b73498770807300935o6045679aq4dcedf6ffd073a2d@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | Postg스포츠 토토 사이트SQL : Postg스포츠 토토 사이트SQL 메일 링리스트 : 2008-07-30 이후 PGSQL-PHP 16:35 |
Try this:
$db = pg_connect("host=localhost port=5432 dbname=med user=med
password=0tscc71");
if (!$db)
{
die("Could not open connection to database server");
}
// generate and execute a query
$query = "SELECT description FROM glossary_item WHERE
name='Alcohol'";
$result = pg_query($db, $query) or die("Error in query: $query.
" . pg_last_error($db));
// Print result on screen
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
foreach ($line as $col_value) {
echo $col_value."<br />";
}
pg_close($db);
The result set is an array, You just need to loop through it. The php
manual has some nice examples that helped me get started.
--------------------------------
Matthias Ritzkowski
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Treat | 2008-07-30 16:38:39 | Re: display query results |
Previous Message | Spiegelberg, Greg | 2008-07-30 16:29:15 | Re: display query results |