I tried to redirect my form to a specified url when the sum of the column 'aantal' of all records reaches a certain amount (e.g. 15).
I tried to put this code in a custom code action in the 'On load' action but this doesn't work:
I tried to put this code in a custom code action in the 'On load' action but this doesn't work:
<?php
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `#__my_table` ;
";
$db->setQuery($query);
$aantal = mysql_fetch_array(mysql_query("SELECT SUM(aantal) FROM #__my_table"));
if ( $aantal >= 15 ) {
// Redirect to my url
$app =& JFactory::getApplication();
$app->redirect('myurl');
}
?>
Hi geertmartens,
Please try
Bob
Please try
<?php
$db = JFactory::getDBO();
$query = "
SELECT SUM(`aantal`)
FROM `#__my_table` ;
";
$db->setQuery($query);
$aantal = $db->loadResult();
if ( $aantal >= 15 ) {
// Redirect to my url
$app = JFactory::getApplication();
$app->redirect('myurl');
}
?>
Bob
This topic is locked and no more replies can be posted.