to all who can help:
i'm working on my first php (and for that matter oop) script. i'm a little confused about something. right now, i have three different files: a class file, a function file (for connecting to my db mostly) and my main.php. i'm going to type out the code to show now:
<?
//function.inc
//db access parameters
$host //blah, blah, blah
function printResults($result){
printf ("<TABLE BORDER=1>");
foreach ($result as $row) {
printf ("<TR><TD>%s</TD></TR>", $row)
}
printf ("</TABLE>");
}
?>
NEXT FILE
<?
//books.inc
//defining the book class
include_once (../functions.inc");
class Books
{
//define the properties
var $book_id;
var $author;
var $title;
//define the methods
function selectBooks() {
$query = "select * from books where book_id = ".$this->book_id;
$result = pg_exec($GLOBALS[connection], $query);
printf ("results: %s", pg_numrows($result));
printf("author:%s",pg_fetch_array($result));
printf ("title %s",pg_fetch_array($result));
printResults ($results);
}
?>
NEXT FILE
<?
//main.php
//create instance of class Books
$b = new Books();
//select book that you want to view
$b->book_id = 2;
//call select method for books
$b-> selectBooks();
?>
what i want it to do is to print out the name of the author and title of book_id #2. it's not doing this though, and for the life of me i cannot figure out how to. i've tried reading the manuals, but still can't seem to get it working. if anybody can help me solve my problem or at least point me in the right direction, it would be greatly appreicated.
(do i have to set up an array using the columns of my db table? am i not correctly setting a variable somewhere ($result in fetch_array)).
ps- sorry about the length of the post. just wanted to make it as complete as possible.
mike z