FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Functions for Hooks Module
#1
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)
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.
Reply
#2
Thanks for sharing!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)