Theres a lot of concepts in your question, lets run through it:
First you need to CREATE TABLE:
CREATE TABLE person (
id SERIAL PRIMARY KEY,
fullname TEXT NOT NULL,
dob DATE,
bio TEXT NOT NULL
);
Insert some test data:
INSERT INTO person (fullname, dob, bio) VALUES
('Steve Jobs', '1955-02-24', 'Steven Paul "Steve" Jobs...'),
('Tutankhamun', NULL, 'Tutankhamun (alternately spelled...');
To make searching faster you should create a full text index on the column you plan to search on:
CREATE INDEX person_fts ON person USING gin(to_tsvector('english', bio));
In your PHP script you will have to connect to PostgreSQL:
$dbconn = pg_connect("dbname=mary");
Now you can do a full text search with pg_query():
$words = "steve jobs";
$sql = "SELECT * FROM person WHERE to_tsvector(bio) @@ to_tsquery('$words')";
$query = pg_query($dbconn, $sql);
if(!$query)
die("An error occured.\n");
If you want to return everthing like you see it in psql then render the records to a TABLE:
echo "<table>";
while($row = pg_fetch_row($result)) {
echo "<tr>";
foreach($row as $cell)
echo "<td>{$cell}</td>";
echo "</tr>";
}
echo "</table>";