I am trying to create a condition in which basis
Column Name Field Name Field Value
of mysql database, a conditional script should show in - Attached Table
ColumnName - FormId Fieldname - Listing Fieldvalue - Listing Value
Below is script
$max = 1;
$listing = JRequest::getInt('listing');
if($listing) {
$db = JFactory::getDBO();
$db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submission_values WHERE `FormId`='".(int) $formId."' AND `FieldName`='listing' AND `FieldValue`='".$listing."' ");
$nrSub = $db->loadResult();
if ($nrSub >= $max) {
$formLayout = '<p>Sorry, no more submissions are accepted for this car.</p>';
}
}
I think am messing up with Fieldvalue column - may be it might not be able to fetch in value. Can someone help and advise pls
You are Quering count, it should be column names or *
for all columns, if you need values, see example below:
$db->setQuery("SELECT * FROM #__rsform_submission_values WHERE `FormId`='".(int) $formId."' AND `FieldName`='listing' AND `FieldValue`='".$listing."' ");
$nrSub = $db->loadAssocList();
print_r($nrSub);
Additionally, Please go through with for ref Joomla DB Documentation
EDIT:
$Query = "SELECT
COUNT(`SubmissionId`) SubmissionCount, `FormId`, `FieldName`, `FieldValue`
FROM #__rsform_submission_values
WHERE `FormId`='".(int) $formId."' AND `FieldName`='listing' AND `FieldValue`='".$listing."'
GROUP BY `FormId`, `FieldName`, `FieldValue`";
$db->setQuery($Query);
$nrSub = $db->loadAssocList();
print_r($nrSub);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.