Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 696B9650090 for ; Wed, 30 Jul 2008 14:49:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 45822-09 for ; Wed, 30 Jul 2008 14:49:10 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by postgresql.org (Postfix) with ESMTP id D1A106501AD for ; Wed, 30 Jul 2008 14:49:11 -0300 (ADT) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=UTF-8; format=flowed Received: from [192.168.0.51] ([96.21.103.185]) by VL-MH-MR002.ip.videotron.ca (Sun Java(tm) System Messaging Server 6.3-4.01 (built Aug 3 2007; 32bit)) with ESMTP id <0K4T009MSYT79CQ0@VL-MH-MR002.ip.videotron.ca> for pgsql-php@postgresql.org; Wed, 30 Jul 2008 13:48:44 -0400 (EDT) Message-id: <4890A983.2040005@videotron.ca> Date: Wed, 30 Jul 2008 13:48:51 -0400 From: PJ User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) To: Matthias Ritzkowski Cc: pgsql-php@postgresql.org Subject: Re: display query results References: <48909454.7040305@videotron.ca> In-reply-to: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200807/6 X-Sequence-Number: 3870 Doesn't work... and I feel totally lost. I don't understand the pg_fetch_* stuff at all. One would think that my query should return the text that is in the field. The database is quite correct and does work with php since it comes from an older web-site that someone else programmed for me. I'm using it to practice and learn. :) Matthias Ritzkowski wrote: > 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."
"; > } > > 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 > >