Opus Pro Tutorial:
You will be unable to use the original script to retrieve data from the database as the HTTP_POST_VARS functions are only able to import post data and cannot send information back to the publication.
To send information back to the publication, you will need to pull the records from the database into an array (using the mysql_fetch array() function), assign each of the strings to an index of the returned array, then issue name-value pairs using the echo function. For example:
<?php $DBhost = "localhost"; $DBuser = "username"; $DBpass = "password"; $DBName = "mydb"; $connect = mysql_connect($DBhost,$DBuser,$DBpass); $db = mysql_select_db($DBName,$connect); $query = "SELECT * FROM employees"; $result = mysql_query($query, $connect); $row = mysql_fetch_array($result ); $data = "&first=".$row['first']."&last=".$row['last'].n ↵ "&address=".$row['address']."&position=".$row['position']; echo $data ?>
Important note: For clarity of layout, the line:
$data = "&first=".$row['first']."&last=".$row['last'].n ↵ "&address=".$row['address']."&position=".$row['position'];
has been wrapped. In your script it should be on a single line, without the " ↵".
You will again need to ensure that the username and password values on lines 4 and 5 are changed to a user who has read/write access to the 'mydb' database.
Now save this file in the document root of your web server with the file name select.php.
Now launch Opus, create a blank new publication and perform the following steps:
Now preview the publication. The first records from the database should be displayed in the text boxes.
using MySQL and php in Opus Pro