Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 2:26 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Populating a listbox with mySQL. Help please.
PostPosted: December 13th, 2010, 1:37 pm 
Offline

Joined: March 26th, 2009, 12:56 pm
Posts: 22
Location: Chester, UK
Dear all,

I originally posted this in the basics section as I consider myself a novice with regards to Opus, but because it contains a database issue, I've now put in here.

I've got a web based publication to interact with a mysql database (login etc), but I just cannot populate a listbox. I've done this in the past with access with a .exe publication, but I am completely stumped with mysql. I've been trying for days with all sorts of variations but I just cannot get it to populate a list box. I know it will be something quite easy, unless you are a novice, but I just do not know where to turn. Any help would be enormously appreciated.

Heres hoping in advance,

Simon


You do not have the required permissions to view the files attached to this post.

_________________
Opus Pro 6
Acer Aspire 5051
AMD Turion 1.6GHz
2GB RAM
XP SP2


Top
 Profile  
 
 Post subject: Re: Populating a listbox with mySQL. Help please.
PostPosted: December 13th, 2010, 2:11 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Hi Simon,

I've had a quick peek, but it's not a simple fix as there seems to be a lot going.

I cannot tell whether the SQL works as it's not pointing at your database, but you seem to be trying to return all rows in the PHP using a loop. This won't work with Opus, you need to return one row at a time or do some clever scripting to build one hell of an array to hold all data as the string. The other bit to populate the box does actually work - sort of. It'll put the value varTwo1 into the box. But then you have some unused function script dropped in that does nothing (?).

I'd take a step back and create a static array such as myList = new Array(1,2,3,4,5,6)

Then solve the script to get the values into the listbox.

Once you've got that working, work on getting the database values in to an (the) array and then connect the two.

Regards,

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Last edited by mackavi on December 13th, 2010, 3:16 pm, edited 1 time in total.

Top
 Profile Visit website  
 
 Post subject: Re: Populating a listbox with mySQL. Help please.
PostPosted: December 13th, 2010, 2:56 pm 
Offline

Joined: March 26th, 2009, 12:56 pm
Posts: 22
Location: Chester, UK
Thanks Russell,

I've used the php scripting advice in the tutorials to send and receive info for individual records and it's working great.

I was hoping to go one step further by using a query with the variable from the first list box to send back the info to populate the second listbox from an array.

I've not used php or mysql before, but have previously used this function with access, again by using advice gained in the forum.

The webhost that I am using offers both mysql and SQL server databases. Would it be any easier if I downloaded the ODBC driver for mysql and basically replaced the DSN location? As mentioned, I am a novice so may be talking gibberish.

Regards

Simon

_________________
Opus Pro 6
Acer Aspire 5051
AMD Turion 1.6GHz
2GB RAM
XP SP2


Top
 Profile  
 
 Post subject: Re: Populating a listbox with mySQL. Help please.
PostPosted: December 14th, 2010, 5:45 pm 
Offline

Joined: March 26th, 2009, 12:56 pm
Posts: 22
Location: Chester, UK
Dear all,

Near yet so far. If I put in an actual value from the database into the php page (as below) everything works great and populates the listbox. However if I replace the Actual_variable with $HTTP_POST_VARS['text_input_variable']; nothing happens?


PHP Page
<?php
$enquiry = 'Actual_value';

$DBhost = "databaselocation";
$DBuser = "username";
$DBpass = "password";
$DBName = "dbname";

$connect = mysql_connect($DBhost,$DBuser,$DBpass);
$db = mysql_select_db($DBName,$connect);

$query = "SELECT three FROM tbl WHERE two LIKE '$enquiry'";
$result = mysql_query($query, $connect);

while ($row = mysql_fetch_assoc($result)){

echo $row['three']."\n";}

?>

This returns to a variable called test.


To populate the listbox

Listbox1.SetSelection(0, -1);
Listbox1.ReplaceSelection("");

wait(0)

var myList = test.split(String.fromCharCode(10))

Listbox1.ReplaceSelection(myList.join(String.fromCharCode(10)))
function removeElement(x)
{
var t = 0
if (myList.length > 1)
{
for (i=0;i<myList.length;i++)
{
i == x ? t = 1 :myList[i-t] = myList[i]
}
myList.length = myList.length-1
Listbox1.SetSelection(0,-1)
if (x == 0) Listbox1.ReplaceSelection("")
Listbox1.ReplaceSelection(myList.join(String.fromCharCode(10)))
}
Listbox1.SetListBoxSelection(-1)
}

Any reason why it's not reading the posted variable yet everything works if it is typed in on the PHP page. I'm baffled and look forward to any advice.

Best regards

Simon

_________________
Opus Pro 6
Acer Aspire 5051
AMD Turion 1.6GHz
2GB RAM
XP SP2


Top
 Profile  
 
 Post subject: Re: Populating a listbox with mySQL. Help please.
PostPosted: December 14th, 2010, 7:13 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Use $_POST[] instead.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: Populating a listbox with mySQL. Help please.
PostPosted: December 14th, 2010, 10:00 pm 
Offline

Joined: March 26th, 2009, 12:56 pm
Posts: 22
Location: Chester, UK
Thanks Mack,

As yet no joy with it, but I've just tried a few variations. Unfortunately my brain is now fried and I'm afraid my variations will mess up the original script, so I'll try again in the morning.

Many thanks.

Simon

_________________
Opus Pro 6
Acer Aspire 5051
AMD Turion 1.6GHz
2GB RAM
XP SP2


Top
 Profile  
 
 Post subject: Re: Populating a listbox with mySQL. Help please.
PostPosted: December 14th, 2010, 11:25 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Doesn't need varying.

Here's a simple example running off a basic script on our server.

Mack


You do not have the required permissions to view the files attached to this post.

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: Populating a listbox with mySQL. Help please.
PostPosted: December 14th, 2010, 11:52 pm 
Offline

Joined: March 26th, 2009, 12:56 pm
Posts: 22
Location: Chester, UK
Thanks again.

Had a quick play and of course yours worked perfectly. It's something I must be doing in the script somewhere so will will work on eliminating the mistakes tomorrow. Once again, many thanks.

Simon

_________________
Opus Pro 6
Acer Aspire 5051
AMD Turion 1.6GHz
2GB RAM
XP SP2


Top
 Profile  
 
 Post subject: Re: Populating a listbox with mySQL. Help please.
PostPosted: December 15th, 2010, 10:40 am 
Offline

Joined: March 26th, 2009, 12:56 pm
Posts: 22
Location: Chester, UK
Dear Mack,

Thanks for your advice. The problem was in all the changes I had made, the problem was on the Post Web Data source page where I was trying to send a variable and not a string. When I changed it back to sending a string, it all worked fine. D'oh!

Thanks for the help.

Best regards

Simon

_________________
Opus Pro 6
Acer Aspire 5051
AMD Turion 1.6GHz
2GB RAM
XP SP2


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 45 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group