Search tutorials
Tutorials » Backend: Keyword search using MySQL / PostgreSQL / MSSQL / InterBase / ODBC, PHP and Flash 4 - Page 6
The Answer Script
In the attached zip file are different scripts for each db for returning the answer. Select the one for your database, rename the file to answer.php and place it in the root directory of dgssearch (the same location as search.php)MySQL Answer Script
/*
** answer_mysql.php
** Quick db query to display the answer of the question
** This is necessary because we dont want all the
** answers loading into the flash on the first query.
** Thats why we execute twice.
*/
require("config/config.php");
/* Get the variables from the config file */
$answertable = $database[0]["answertable"];
$server = $database[0]["server"];
$username = $database[0]["username"];
$password = $database[0]["password"];
$database = $database[0]["database"];
/* Get the variables sent from the Flash*/
$id = $HTTP_POST_VARS["id"];
/* Connect to MySQL */
mysql_pconnect($server, $username, $password);
/* Connect to Specified Database */
@mysql_select_db("$database")or die("&theTruth=DatabaseError&answerloaded=1");
/* Find the answer and display it */
$result = mysql_query("select answer from $answertable where id = $id");
while (list($answer) = mysql_fetch_row($result)) {
print("&theTruth=$answer");
}
print("&answerloaded=1");
?>
This PHP script gets executed when you click on one
of the questions that have been returned, it is loaded in the goToLink Call in
the Flash movie.
| » Level Advanced |
|
Added: 2001-02-19 Rating: 8 Votes: 47 |
| » Author |
| I work for a Canadian software company as a logisitics director. We provide custom configured Linux distributions. In my spare time I sleep. |
| » Download |
| Download the files used in this tutorial. |
| Download (103 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!