Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently May 17th, 2024, 9:11 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: multi-row data output
PostPosted: November 15th, 2004, 1:23 pm 
Offline

Joined: November 15th, 2004, 1:16 pm
Posts: 1
Location: scotland
This is probably an oft-asked question. I've used Opus since it was Illuminatus 3 and bought Opus Pro as soon as it was announced. BUT I'm only now using the database facilities for the first time.

Getting data from a database and outputting the first row is easy. Doing a previous/next is easy. But what if I want to output a list of something. I get, say, 100 records from the table. How do I show all 100 in a scrollable text area?

I wrote a script that iterates through the recordset and assigns the values of each tuple (row) to a set of variables but only the last one is shown.

Does this mean that I now need to provide a separate set of variable instances for each tuple? I tried copying and pasting the variable 'placeholders' but that doesn't work. It seems a lot of work for what must be a routine requirement.

All ideas gratefully received


For this message mmci has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: November 15th, 2004, 1:55 pm 
Offline

Joined: October 25th, 2004, 12:27 pm
Posts: 526
Location: Digital Workshop
Hi,

Thank you for your enquiry.

This can be achieved using multiple text objects (to display the returned records) and a looped script query. Please find below a link to download a zip folder containing a sample database, DSN and three publications of increasing complexity to demonstrate this in action.

I hope this helps. Please do not hesitate to contact me if you have any further queries.

Kind regards,


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

_________________
Robin Garrett
Digital Workshop Technical Support


For this message Robin Garrett has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 15th, 2004, 3:47 pm 
Hi Robin

I came to one of your workshops back in February(ish) and found it very useful.

Thanks for your suggestion. I had worked that one out before posting - I had set it for 10 to a page.

What I'm trying to achieve, though, is an entry list of 88 people for an event, all displayed in one batch, using a scrollbar to move down the list.

It looks like the only way that I can achieve this would be to define 88 individual rows - name1, name2, name3 to name 88. The disadvantage of this is that, if the next event has 89 entries, I would need to add another row to the page. Which kind of gets away from the recursive nature of database output.

If you know ASP, you'll know that you can iterate through a recordset (the following is paraphrased):

Do while Not RS.EOF // do this for each record returned by the query

RS("name") <br> // output the name for the current row

RS.MoveNext // check whether there are any more records


That is, for every record returned by the query, show the output on a new line. No need to define the lines, or to create container objects. One line is created for each record returned. 10 records = 10 lines. 88 records = 88 lines.


Can I write a script that creates 'n' child rows? I suppose I would need a 'createChild' function for that, so maybe it's not possible

Malcolm


Top
   
 
 Post subject:
PostPosted: November 15th, 2004, 5:41 pm 
Offline

Joined: October 25th, 2004, 12:27 pm
Posts: 526
Location: Digital Workshop
Hi,

Thank you for your enquiry.

It is possible to use one text box to display the results, which can cater for any number of returned records. For example, try the following:

- Open the scriptDB_Example3 sample publication
- Delete the five 'Text' and 'Surname' objects which are currently set to display the returned results
- Add a text object to the page
- Name the text object Textbox and give it a vertical scrollbar
- Now open the Script 1 object on the page
- Modify the ShowRecords() function to read the following:

Code:
function ShowRecords()
{
   text = ""
   if (records == null) {
      return;  // need to call Search First to get records
   }
   
   var num_records = records.GetNumberOfRecords();
   for (num=1; num <= num_records; num++)
   {
      Textbox.SetSelection(0, -1); // Select all text in box
      if (num <= (num_records - Start_Record_Num + 1)) {
         text = text + (records.First_Name + " " + records.Surname + "\n")
         Textbox.ReplaceSelection(text);
      } else {
         Textbox.ReplaceSelection("");   // Clear the text box
      }
      records.NextRecord();
   }
}


This will display the results of the search within the Textbox object, with the First_Name record and Surname record separated by a space and with each record separated by a line return.

I hope this helps. Please do not hesitate to contact me if you have any further queries.

Kind regards,

_________________
Robin Garrett
Digital Workshop Technical Support


For this message Robin Garrett has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 15th, 2004, 9:09 pm 
Hi Robin

Excellent.

I knew it would be possible. It had to be possible. but I just couldn't see it.

Very much appreciated.

Thanks again

Malcolm


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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