Forums

DBMRL, Url Request Params and Arrays

libraguy78 21 Oct, 2011
I'm not sure if this can be done on Chronoforms, but I scoured the message boards for the last week in hopes to find something similar. Sadly I wasn't able to fine anything. So here's what I'm hoping to do:

I want to pass an URL Request Param to a WHERE command, but the problem I'm having is with the handled arrays by using the DB Multi Record Loader.

The form takes the data, and one element is using a checkbox array. In the display list, I was hoping to use the url param (ie &color=red ) and this would be passed to a WHERE in the list, showing only entries that contain "red" in the array. But I only know of using LIKE to search the comma separated array that is saved.

If I need to provide any additional information, let me know! Thank you in advance.🙂
GreyHead 21 Oct, 2011
Hi libraguy78,

I'm sorry, I got lost about paragraph 3. Please can you spell it out with an example.

Bob
libraguy78 22 Oct, 2011
Sorry about that. So in steps, this is what I've been attempting to do.

The form I created has a few text box fields, and one checkbox field. The checkbox field contains multiple values. For example, we'll use the name "colors", which values of Red, Blue, Green, Purple and Yellow. Because of the array, I inserted a "Handle Array" action in the form before it saves to the DB, and uses a comma (,) for a delimiter. So when the data is saved to the DB, it saves in the form like "Red,Blue,Purple".

On the next form, I used the DB Multi Record Loader, as I needed to display a list of the entries placed into the DB. I need to create a filter to display different colors recorded from the checkbox array that was saved earlier. For example, do display all records that contained the color "Red". Normally I would have used the Request Param and DB Field in the DB Multi Record Loader to select certain values to display in the form. But this does not seem to work within the array that is saved through the earlier form, as when multiple colors are selected, it saved similar to "Red,Green,Yellow". I can create individual forms for each filter, using `Color` LIKE 'Red' in the WHERE field, but this makes for an extensive list of forms just for a filter set.

What I'm wanting to do is to be able to use the Request Param and DB Field for filtering the saved array in the DB entry. I hope that this is more explanatory.🙂
GreyHead 22 Oct, 2011
Hi libraguy78,

Ah, got it (I think) thank you.

Try `color` LIKE '%Red%' this should find 'Red' anywhere in the string.

Bob
libraguy78 22 Oct, 2011

Hi libraguy78,

Ah, got it (I think) thank you.

Try `color` LIKE '%Red%' this should find 'Red' anywhere in the string.

Bob



Thats actually what I have been doing for the individual filter forms. But this has caused me to create over 8 forms to filter out each color. What I was looking for was if there was a way to pass the Request Param to the WHERE field through just one form.

Example:

URL would be - http://www.mysite.com/index.php?option=com_chronoforms&chronoform=MyForm&Color=Red

I would like this to cause the same as `color` LIKE '%Red%' in the WHERE field. How is it possible to do this?
GreyHead 23 Oct, 2011
Hi libraguy78,

Sorry, I misunderstood. Please try
<?php
$color = JRequest::getString('Color', '', 'get');
echo "WHERE `color` LIKE '%{$color}%' ";
?>


Bob
libraguy78 24 Oct, 2011
Fantastic! Thank you Grey! Always awesome support.🙂
This topic is locked and no more replies can be posted.