RE: PHP/SQL search engine help (newbie)
| From: | Carlos Andre Marques Moreira | Date: | Mon, 07 Jan 2002 18:16:34 +0000 |
| Subject: | RE: PHP/SQL search engine help (newbie) | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-11339@lists.php.net to get a copy of this message | ||
Hi,
AFAIK PHP don't access MS Access directly so you should access your database
via ODBC.
Here are some ODBC Functions:
int odbc_connect(string dsn, string user, string password, int
[cursor_type]) -> Connect to ODBC, cursor_type is optional
int odbc_exec(int conn_id, string query_string) -> Executes the SQL Query
String
int odbc_fetch_row(int result_id, int [row_number]) -> Retrieve a row from
your query, row_number is optional, if not provided will retrieve next row.
string odbc_result(int result_id, mixed field) -> Retrieve a column, mixed
field could be column name or number
void odbc_close(int conn_id) -> Close the connection to ODBC
Ex1.:
$conn_id = odbc_connect("access","","");
$result = odbc_exec($conn_id, "select * from students");
$result_row = odbc_fetch_row($result);
$student_name = odbc_result($result_row, "name");
Ex2.:
ODBC configuration
dsn name = "access", no user or password set.
Access table
Table name = "thelp"
Columns -> ID, Title, Help
$word is the query string you'll look for into your database
This you'll search the database for $word and then output the help title as
a link to the help description
<?php
$conn_id = odbc_connect("access","","");
$result = odbc_exec($conn_id, "select id, title from thelp where title like
'*$word*' or help like '*$word*'");
while ($result_row = odbc_fetch_row($result)){
?>
<a href="help.php?id=<?php echo odbc_result($result_row,
"id");?>"><?php
echo odbc_result($result_row, "2");?></a>
<br>
<?php
}
?>
For more information see ODBC Functions in the Manual.
Carlos André Marques Moreira
Bolsista CNPq / RHAE
SENAI / CETAE
camoreira@sfiec.org.br
2001 Ano Internacional do Voluntário
-----Original Message-----
From: Keith Hughes [mailto:HannahandKeith@dogeye.freeserve.co.uk]
Sent: segunda-feira, 7 de janeiro de 2002 13:22
To: php-windows@lists.php.net
Subject: PHP/SQL search engine help (newbie)
Hi,
Completely new at this, so don't be too harsh.
I'm trying to create a help file system for a programme (much like the help
files that you get with macromedia flash).
All the help files will be in HTML format and will be in an access database.
I need to search through the database with a search engine, and I assumed
that the best way to do this would be to use a combination of SQL and PHP.
Unfortunately I'm very very new to both. I have a basic grasp of SQL but
hardly any for PHP.
Could anybody give me any tips on how to get started or a link to any good
tutorials?
Thanks for any help
Keith