I am creating a MySQL database of approx. 7000 book records with the following fields
and properties to be inserted, queryed and called by a php script to my web pages.
The dbase looks like this:
author varchar(50)
title varchar(150)
publisher varchar(50)
place varchar(50)
year varchar(4)
subject varchar(50)
abstract varchar(255)
notes varchar(100)
link varchar(100)
item int(4)
The architecture of the database is fine (I think). It is not populated yet except for a few test records. What I need now is a PHP script to query the dbase by author, title, subject, keyword and return the results to html tables. This is not esp. difficult I know from reading various sites but I am having some difficulties getting my script because I'm new to this I guess.
Can someone please point me to a prexisting script that I can modify for this purpose? Or, what I am doing wrong in the script below?
<?php
$db = MySQL_connect('localhost', 'user', 'pass');
mysql_select_db("_library",$db);
$result = mysql_query("SELECT * FROM _library",$db);
printf("Author: %s<br>\n", mysql_result($result,0,"author"));
printf("Title: %s<br>\n", mysql_result($result,0,"title"));
printf("Publisher: %s<br>\n", mysql_result($result,0."publisher"));
printf("Place: %s<br>\n", mysql_result($result,0,"place"));
printf("Year: %s<br>\n", mysql_result($result,0,"year"));
?>
This is just a test script to see if I could get results returned from my library dbase.
What I get is this:
Warning: 0 is not a MySQL result index in /home/oldmom/oldmom-www/catalog/search.php3 on line 7
Author:
Please help or usggest if you can.
Thanks, Rick
and properties to be inserted, queryed and called by a php script to my web pages.
The dbase looks like this:
author varchar(50)
title varchar(150)
publisher varchar(50)
place varchar(50)
year varchar(4)
subject varchar(50)
abstract varchar(255)
notes varchar(100)
link varchar(100)
item int(4)
The architecture of the database is fine (I think). It is not populated yet except for a few test records. What I need now is a PHP script to query the dbase by author, title, subject, keyword and return the results to html tables. This is not esp. difficult I know from reading various sites but I am having some difficulties getting my script because I'm new to this I guess.
Can someone please point me to a prexisting script that I can modify for this purpose? Or, what I am doing wrong in the script below?
<?php
$db = MySQL_connect('localhost', 'user', 'pass');
mysql_select_db("_library",$db);
$result = mysql_query("SELECT * FROM _library",$db);
printf("Author: %s<br>\n", mysql_result($result,0,"author"));
printf("Title: %s<br>\n", mysql_result($result,0,"title"));
printf("Publisher: %s<br>\n", mysql_result($result,0."publisher"));
printf("Place: %s<br>\n", mysql_result($result,0,"place"));
printf("Year: %s<br>\n", mysql_result($result,0,"year"));
?>
This is just a test script to see if I could get results returned from my library dbase.
What I get is this:
Warning: 0 is not a MySQL result index in /home/oldmom/oldmom-www/catalog/search.php3 on line 7
Author:
Please help or usggest if you can.
Thanks, Rick