Situation:
On the frontend of my (Joomla 1.5) website, users can become member of the site by filling in a form.
Two fields in this form are more importent than others. The field Region and the field Capacity.
Region is just a simpel textfield, but capacity is a checkbox, where users can check multiple values, like 10-20, 20-30, 30-40 etc.
I have a MySql query that gives me name, adress, telephone etc, when i provide it with a region and capacity.
The part of the query where i provide region and capacity to the query, looks like this:
===================================
FROM jos_RSFORM_FORMS A
INNER
JOIN jos_RSFORM_SUBMISSIONS B
ON B.FormId = A.FormId
INNER
JOIN jos_RSFORM_SUBMISSION_VALUES C
ON C.SubmissionId = B.SubmissionId
AND C.FieldName = 'regio'
AND C.FieldValue = '134'
INNER
JOIN jos_RSFORM_SUBMISSION_VALUES D
ON D.SubmissionId = B.SubmissionId
AND D.FieldName = 'capaciteit'
AND D.FieldValue LIKE '%10-20%'
WHERE A.FormId = 2
===================================
I would now like to have a form in the backend of the website with two fields, Region and capacity. The corresponding values in the query must be provided by this form.
I have made a php actionscript, but that does not give me any results, so i did something, somewhere apparently wrong.
Here’s the script:
===================================
<?php
$host = "localhost";
$user = "root";
$pass = "";
$dbname = "database";
$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);
$sql = "SELECT A.FormId
, B.SubmissionId
, B.DateSubmitted
, B.UserIp
, ( SELECT FieldValue
FROM jos_RSFORM_SUBMISSION_VALUES
WHERE FieldName = 'Name'
AND SubmissionId = B.SubmissionId ) as Name
, ( SELECT FieldValue
FROM jos_RSFORM_SUBMISSION_VALUES
WHERE FieldName = 'adres'
AND SubmissionId = B.SubmissionId ) as Adres
, ( SELECT FieldValue
FROM jos_RSFORM_SUBMISSION_VALUES
WHERE FieldName = 'telefoon'
AND SubmissionId = B.SubmissionId ) as Telefoon
, ( SELECT FieldValue
FROM jos_RSFORM_SUBMISSION_VALUES
WHERE FieldName = 'email'
AND SubmissionId = B.SubmissionId ) as Email
FROM jos_RSFORM_FORMS A
INNER
JOIN jos_RSFORM_SUBMISSIONS B
ON B.FormId = A.FormId
INNER
JOIN jos_RSFORM_SUBMISSION_VALUES C
ON C.SubmissionId = B.SubmissionId
AND C.FieldName = 'Regio'
AND C.FieldValue = '".$_POST['Regio']."'
INNER
JOIN jos_RSFORM_SUBMISSION_VALUES D
ON D.SubmissionId = B.SubmissionId
AND D.FieldName = 'capaciteit'
AND D.FieldValue LIKE '".$_POST['capaciteit']."'
WHERE A.FormId = 2";
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)) {
echo "<p>",$row['Naam']," | ",$row['Adres']," | ",$row['Email']," | ",$row['Telefoon'];
}
?>
======================================
I think it has something to do with the % marks in the mysql query ?
Can someone help me on this one ?
Thanks in advance,
Mesjoggah