I have been following the tutorials on how to write and read from a external MySQL database.
The writing to database tutorial I have accomplished and with the exception of image data uploading as images, everything else went amazingly well.
I thought reading from the database would be much simpler.
I was wrong. I forgot about how to read ALL the records and then put them into some kind of array - something like that.
I wrote the load.php script (username and password blanked out for obvious reasons):
Code:
<?php
$DBhost = "mfelkerco.com";
$DBuser = "XXXXXXX";
$DBpass = "XXXXXXXXXXX";
$DBName = "mfelker_TB3Memdb";
$connect = mysql_connect($DBhost,$DBuser,$DBpass);
$db = mysql_select_db($DBName,$connect);
$query = "SELECT * FROM members";
$result = mysql_query($query, $connect);
$row = mysql_fetch_array($result );
$data = "&memberid=".$row['memberid']."&membername=".$row['membername']."&membertitle=".$row['membertitle']."&memberpic=".$row['memberpic']."&membercategory=".$row['membercategory']."&businessname=".$row['businessname']."&officephone=".$row['officephone']."&mobilephone=".$row['mobilephone']."&faxphone=".$row['faxphone']."&emailaddr=".$row['emailaddr']."&businesswebsite=".$row['businesswebsite']."&businessdesc=".$row['businessdesc']."&facebooklink=".$row['facebooklink']."twitterlink=".$row['twitterlink']."&linkedinlink=".$row['linkedinlink']."&youtubelink=".$row['youtubelink']."&myspacelink=".$row['myspacelink']."&instagramlink=".$row['instagramlink']."&googlepluslink=".$row['googlepluslink']."&pinterestlink=".$row['pinterestlink']."&isplatinummember=".$row['isplatinummember']."&memberjoindate=".$row['memberjoindate']."&bcfrontpic=".$row['bcfrontpic']."&bcbackpic=".$row['bcbackpic']."&platinumbannerpic=".$row['platinumbannerpic'];
echo $data
?>
and then created the form (member directory form) in Opus Pro to read from the database. I followed the tutorial to the letter (I simply have more fields, though) and
created all the text boxes with variables and did the 'on show' trigger with 'post to web' action (with the correct URL for the load.php file) and put all the strings and
variables as a multi in the DESTINATION tab. I do get the 1st record to show, but no others. I am not sure how to go back and forth between records.
One thing I did notice is that in the tutorial, they assume one record only, so memberid (my auto increment field) is not accounted for.
I also put forward, backward and search buttons on the form. I want forward and backward to simply go back and forth between database records. The search button goes
to another form with search boxes for name and category (those do not show up either). The idea there is to have a listbox (I would prefer a dropdown box, but cannot find
one) so that the user can select the name or category and then find that record and go to it in the member directory form.
My questions are: How can I read the memberid field and then use that to go back and forth between records? How can I read ALL records in the database (from a specific field -
membername and membercategory) and have them all show up in list boxes? How can I choose a record from a listbox (name or category) and then load that specific data to
the member directory form text boxes (for example, in the names list box there are 20 names and I pick one, now I want that name's record to show up on the member
directory form)?
I can post the project file if needed.
Thank you for your help.
Mike