Forums

SELECT menu and WHERE condition

ynternet 09 Mar, 2013
Hi๐Ÿ™‚

I have table with many GROUPS. I need to use SELECT menu to choose GROUP... Than I need to send this WHERE condition to this same ChornoConnectvity and show table with only selected GROUP.

GreyHead 09 Mar, 2013
Hi ynternet,

I know that this is possible because that's how the Category drop-down in the FAQs list here works. But I'm not clear how Max set it up. I know that it uses a ChronoForm 'task' for the search box and the Category.id is used as a filter but not much more than that.

Hopefully Max will be able to explain more.

Bob
ynternet 10 Mar, 2013
Thank you Bob,

so I need to wait for Max and his solution๐Ÿ™‚
OKee๐Ÿ˜‰
Max_admin 10 Mar, 2013
Hello,

You will need to enter the "Group" column name (in the database table) in the "Filters fields names" box under the "Search settings" tab, please follow the instructions under the box there, so ify our "Group" column is called "group" then the filter field name (the dropdown in your case) should be:

filter_group

and if you have a model name XYZ then the name should be:

filter_xyz_group

I hope this helps!๐Ÿ™‚

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ynternet 11 Mar, 2013
Thank you Max and Bob.

I have in "Custom listing settings" in HEAD:

<script>
window.addEvent('domready', function() {
  $('filter_group').addEvent('change', function() {
      var group = $('filter_group').value;
      window.location = '?filter_group='+ group;
  });
});
</script>

<?php
$db2 =& JFactory::getDBO();
$query2 = "SELECT DISTINCT `group_name`,`CF_ID` AS `ID`
          FROM `#__chronoforms_data_groups`
          ORDER BY `CF_ID`;
         ";
$db2->setQuery($query2);
$data2 = $db2->loadObjectList();
?>

<form action="groups/group-list" method="post" name="form2">
<label for="filter_group">Group :</label>
<select size="1" type="select" name="filter_group" id="filter_group" >
<option value="all">All groups</option>
<?php
$get_group = JRequest::getString('filter_group', '', 'get');
foreach ( $data2 as $d2 ) {
   $selected = ($d2->ID == $get_group) ? "selected" : "";
   echo "<option value='".$d2->ID."' ".$selected.">".$d2->group_name."</option>";
}
?>
</select>
</form>


in "Filters fields names" in "Search settings" filter_group

in "General" in "WHERE SQL" :

<?php
$where_group = JRequest::getString('filter_group', '', 'get');
if ( $where_group && $where_group != 'all') {
  echo "`group_name` = '$where_group' ";
}
?>

When I select some group (for example group number 1), it works and just group number 1 is in the table. But when I try sort some column (for examle cf_UID) - "sort" works, but SELECT menu does not work. Every group from database are in the ChronoConnectivity table.
ynternet 11 Mar, 2013
I have yet another one problem with this ChronoConnectivity table.

In the "Footer" i have this code :

</tbody>
</table>
{pagination}

But pagination is not working...
GreyHead 12 Mar, 2013
Hi ynternet,

I'm not sure about the filter problem but I think the pagination is now {paginator}

Bob
ynternet 12 Mar, 2013
Thanx Bob, paginator works fine...

So with problem with filter, we have to wait for Max.๐Ÿ™‚
Max_admin 13 Mar, 2013
Hi,

The core filters work when used with fixed where SQL, I'm not sure if its going to work after adding extra conditions to the WHERE statement using PHP๐Ÿ˜Ÿ

also the filters fields names box should take the table's columns names to be filtered, not the fields names, a bit misleading, sorry!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ynternet 14 Mar, 2013
Thank you Bob and Max,

I have another problem...

I have defined object $data2 in the "HEAD" :

$data2 = $db2->loadObjectList();


But when I use this in the "BODY"

echo $data2[0]->group_name;
echo $data2[1]->group_name;
echo $data2[2]->group_name;

It seem to me, that there is no object $data2 in the BODY. Is there some solution to pass object, variable, array or somethig from HEAD to BODY ?
GreyHead 14 Mar, 2013
Hi ynternet,

You have a 'scope' problem here. When you define a variable in the Head box it is only valid in that box. You need to define it as global before it is set to make it available in the body box.
<?php
global $data2;
. .  .
$data2 = $db2->loadObjectList();
. . .
?>

<?php
global $data2;
. . .
echo $data2[0]->group_name;
echo $data2[1]->group_name;
echo $data2[2]->group_name;
. . .
?>


Bob
ynternet 14 Mar, 2013
thanx Bob,

it works... I forgot insert
global $data2;
into BODY...
This topic is locked and no more replies can be posted.