Mar 12th, 2013, 6:54 AM
I am working on a project that hooks to the code hook "ft_get_submission,end" and I have come up with a few functions that I use and may be helpful to others. I know they work with this code hook, they may work with others.
Store a value to a given field (column) for the current record(submission)
Get a value of a given field (column) from the current record(submission)
I use the following to help with debbuging when I need to see what is happening with a variable
Please let me know if I can improve on these in any way.
Store a value to a given field (column) for the current record(submission)
PHP Code:
function store_value($table_prefix, $form_id, $submission_id, $column_name, $value)
{
$query = "
UPDATE {$table_prefix}form_{$form_id}
SET $column_name = $value
WHERE submission_id = $submission_id
";
@mysql_query($query);
}
Get a value of a given field (column) from the current record(submission)
PHP Code:
function retrieve_value($table_prefix, $form_id, $submission_id, $column_name)
{
$query = "
SELECT *
FROM {$table_prefix}form_{$form_id}
WHERE submission_id = $submission_id
LIMIT 1
";
// mysql_fetch_assoc() gets an associative array that represents a result row, where the array keys are the field names.
$result = mysql_query($query);
$retrieved_row = mysql_fetch_assoc($result);
return $retrieved_row[$column_name];
}
I use the following to help with debbuging when I need to see what is happening with a variable
PHP Code:
function show_popup($message)
{
echo '<script type="text/javascript">
window.onload=function(){alert("' . $message . '");}
</script>';
}
Please let me know if I can improve on these in any way.