Hi everyone. Here's my problem.
How can I nicely retrieve data from field "extra" from table webform_component. That's from webform module.
All the forms are having either select or txtarea type.
I've also created extra field in above mentioned table. I have a separate form that's placing values in them.
Now when i want to retrieve the values from submission I'm hitting wall on select radio buttons.
The data in field extra is serialized.
Aftere retrieving needed data by sql, i'm using "if.. ifelse" function defining that if type is select do radios if textarea do texarea.
but if i do radios (after unserializing) I get something like this:
o list of all values o0o0o0o
o in this example is radio button
Here is my code. The code isn't exactly logical or efficient, specially sql but i'm trying to figure out this problem first.
$sql_components = "SELECT DISTINCT name, extra, summary, type\n"
. "FROM webform_component\n"
. "JOIN webform_submitted_data ON webform_component.nid = webform_submitted_data.nid\n"
. "WHERE webform_submitted_data.nid=19 AND webform_submitted_data.sid=30\n"
. "ORDER BY webform_component.weight ASC LIMIT 0, 30 ";
$sql_data = "SELECT distinct webform_submitted_data.nid, webform_submitted_data.sid, webform_submitted_data.cid, webform_submitted_data.data\n"
. "FROM webform_submitted_data\n"
. "JOIN webform_component ON webform_submitted_data.nid = webform_component.nid\n"
. "WHERE webform_submitted_data.nid=19 AND webform_submitted_data.sid=29\n"
. "ORDER BY webform_submitted_data.cid ASC LIMIT 0, 30 ";
$doComponentsQuery = mysql_query($sql_components);
$doDataQuery = mysql_query($sql_data);
$checked[$type] = "checked";
while($result=mysql_fetch_array($doComponentsQuery))
{
$data=mysql_fetch_array($doDataQuery);
$type = $result['type'];
echo $result['name'];
echo "<br>";
// type is radios--------------------------------------
if ($type == select)
{
$extra = unserialize($result['extra']);
echo "<form>";
foreach ($extra as $values)
{
echo "<input type=\"radio\" enabled=\"disabled\" name=\"extra\" $checked/>";
echo $values;
}
echo "</form>";
echo $result['summary'];
echo "<br><br>";
}
// type is texarea------------------------------------------
elseif ($type == textarea)
{
echo "<form>";
echo "<type=\"text\" enabled=\"disabled\" name=\"summary\" readonly=\"readonly\">";
echo $data['data'];
echo "</type>";
echo "</form>";
echo $result['summary'];
echo "<br>-------------------------------------------<br>";
}
// something else display ths message
else
echo "Error in node # script!";
}
1 more thing
when creating webfrom radio options are coded, i.e:
0| this is text
7| this is txt too
value for option | description
I thought it was easy to just
I thought it was easy to just download a csv or xls file of all submission from the view page . Too easy a solution ?
not really a solution for my purpose
what i want to achieve is when user submits the webform (limited to only 1 submission) whenever he opens it again he will see the form with all the things he submitted. This is alredy done by a small change in webform.module file.
But what I also want is that, only after he submits the form, below every question will show the custom summary.
now i don't think i can do it by alterting webform.module file itself.
so my idea is to create a separat node that shows to currently logged user his last submitted form. The only problem I'm having is with those damn radio buttons :/
Have you tried
giving them permissions to see their own submission
i.e. tick "access own webform submissions" for authenticated users