Hello all,
i have started my first projekt with Chronoforms ... and as expected i have my first problem π
I created a Form to save data to a database. That was easy. ( With this forrum ...π ). Next step would be a check before saving if this data already exists in the database. I have two field with prename and surename. I want to check if there is already a combination of this in the database or not.
I found the EVENET SWITCHER. For first test i just have two Display Message event for both cases. One Returns "Data ok" the other " Data exists"
My problem is now, that there is never any Message displayed. I fear i have a error in my code so no case is occured ...
Can anybody help me ?
Thx and Greets from Germany
... my code for the event switcher is :
i have started my first projekt with Chronoforms ... and as expected i have my first problem π
I created a Form to save data to a database. That was easy. ( With this forrum ...π ). Next step would be a check before saving if this data already exists in the database. I have two field with prename and surename. I want to check if there is already a combination of this in the database or not.
I found the EVENET SWITCHER. For first test i just have two Display Message event for both cases. One Returns "Data ok" the other " Data exists"
My problem is now, that there is never any Message displayed. I fear i have a error in my code so no case is occured ...
Can anybody help me ?
Thx and Greets from Germany
... my code for the event switcher is :
<?php
$db =JFactory::getDBO();
$query = "
SELECT `id`
FROM `#__Data_Player`
WHERE `player_vn` = '{$form->data['player_vn']}'
AND `player_nn` = '{$form->data['player_nn']}'
";
$db->setQuery($query);
$num_rows = $db->getNumRows()
if ($num_rows === 0) {
return "fail";
} else {
return "success";
}
?>
Hello TRIJ,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
Event switcher
P.S: I'm just an automated serviceπ
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
Event switcher
P.S: I'm just an automated serviceπ
Please debug this line of code, using an "echo" statement in a "custom code" action:
Does it work as expected ?
Regards,
Max
$query = "
SELECT `id`
FROM `#__Data_Player`
WHERE `player_vn` = '{$form->data['player_vn']}'
AND `player_nn` = '{$form->data['player_nn']}'
";
Does it work as expected ?
Regards,
Max
Hi Max,
if i use an "echo" for the colplete expression i get nothing. if i insert an "echo ($query);" after the expression i get a message in form of :
SELECT `id` FROM `#__data_player` WHERE `player_vn` = 'Tim' AND `player_nn` = 'IJsselstein'
i tried a "echo ($num_rows); but i there is now message thenπ
Regards
Tim
if i use an "echo" for the colplete expression i get nothing. if i insert an "echo ($query);" after the expression i get a message in form of :
SELECT `id` FROM `#__data_player` WHERE `player_vn` = 'Tim' AND `player_nn` = 'IJsselstein'
i tried a "echo ($num_rows); but i there is now message thenπ
Regards
Tim
Hi TRIJ,
Please try this version:
Bob
Please try this version:
$db = JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `#__Data_Player`
WHERE `player_vn` = '{$form->data['player_vn']}'
AND `player_nn` = '{$form->data['player_nn']}' ;
";
$db->setQuery($query);
$count = $db->loadResult();
$result = 'fail';
if ( $count > 0 ) {
$result = 'success';
}
return $result;
?>You may also need to add some validation to check that the values in $form->data[''] exist and are set.
Bob
This topic is locked and no more replies can be posted.
