RE: [PHP-DB] PHP+ postgresql help?

2001-08-20 Thread Jason

first, make a function called query or something for pg_Exec ($conn, $sql);

in this example though you would do

$res = pg_Exec ($conn, $sql);
for($i=0; @$row=pg_fetch_array($res, $i); $i++) {
echo "$row[first] $row[last] "

}


that will loop through the results. make sure your actual query statement is
correct though, the one below is not.

> -Original Message-
> From: Smileyq [mailto:[EMAIL PROTECTED]]
> Sent: Monday, August 20, 2001 7:53 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] PHP+ postgresql help?
>
>
> Hey I'm new to php and using databases. I've setup a postgres server and
> have already populated the database. I'm able to connect the the server
> just fine with php my problem is showing the results. Can somebody show
> me a easy to understand example. For example. I've got a address book
> database setup. I want to be able to search for first names. I'm using
>
> $conn = pg_connect ("host=localhost user=username password=password
> bname=dbname");
>
> I then have a sql statement setup as such
> $sql = "SELECT * FROM database where lower('$name%') order by last;";
>
> I then execute the sql statement
>
> pg_Exec ($conn, $sql);
>
> Now I want to be able to diplay the results on a page no tables or forms
> just a simple output I'll work on layout later. I've trying to do so
> using. pg_result. If anybody could help me I would greatly appreciate
> it. Thanks guys.
>
> -Smileyq
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP+ postgresql help?

2001-08-20 Thread speedboy

> print_r?  Am I about to learn something new?  Be still, my beating heart!

print_r will print the array $row which is one of the rows returned by
running your query. You can then see all the values in the array.

Just run it, you will see what it does.

Or alternatively echo just one field from the returned row (array):

echo "$row[0]";
echo "$row[id]";


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP+ postgresql help?

2001-08-20 Thread Ted Rolle

print_r?  Am I about to learn something new?  Be still, my beating heart!

On Tue, 21 Aug 2001, speedboy wrote:

> > $conn = pg_connect ("host=localhost user=username password=password
> > bname=dbname");
> >
> > $sql = "SELECT * FROM database where lower('$name%') order by last;";
> >
> $result = pg_exec($conn, $sql);
>
> for ($i = 0; $i < pg_numrows($result); $i++) {
>   $row = pg_fetch_array($result, $i);
>   echo "";
>   print_r($row);
>   echo "";
> }
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] PHP+ postgresql help?

2001-08-20 Thread speedboy

> $conn = pg_connect ("host=localhost user=username password=password 
> bname=dbname");
> 
> $sql = "SELECT * FROM database where lower('$name%') order by last;";
> 
$result = pg_exec($conn, $sql);

for ($i = 0; $i < pg_numrows($result); $i++) {
$row = pg_fetch_array($result, $i);
echo "";
print_r($row);
echo "";
}


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]