Welcome, Guest
  • Page:
  • 1

TOPIC: INSERT query UPDATE?

INSERT query UPDATE? 3 years, 10 months ago #1386

Hi,

here I am again... I used this code to show the values that are entered before by the logged in user. But when I edit the data, it saves it in the database with a new record_id. However, I would like to update the existing record in stead of save new information in the database. Do you have a simple solution for this? How would you do this?

Thanks a lot!

Gr, Jan


/* Before Form Piece for retrieving all the subrecords from a previous visit */
//+trace dis

// configuration variables
$register = 1;  // 0 = public access, 1 = registred users only

// load the standard piece library
$this->execPieceByName('ff_InitLib');  
global $user_id;
global $query, $rows; 
// check for registred users
// if ($register && JFactory::getUser()->get('id',0) == 0) 

// { $this->page = 2; } else {

$user_id = JFactory::getUser()->get('id');

/* Get the key id number from the log record here using record_id */
if ($user_id != '') {
    $query = "select record from #__facileforms_subrecords where value = '";
    $query .= $user_id;
    $query .= "' and name = 'UserID'";
    echo "Query one is " . $query . "<br>\n";  /*<---showing the query for debugging purposes */
    $dbrec_id = ff_selectValue($query);
    
    echo '<b>'.$dbrec_id.'</b>';

    /*  Now get all the values from the log file with proper id*/
    $query = "select name, value as valx from #__facileforms_subrecords where record = '";
    $query .= $dbrec_id;
    $query .= "'";
    $rows = ff_select($query);
    $cnt = count($rows);
    echo " Query returned " . $cnt . " rows " . "<br>\n"; /*<--show the 2nd query for debug */

    foreach ($rows as $row ) {
     switch ($row->name) {       /*  The echo's are for debugging purposes only */
//         case 'cf_name'     : echo "Found res_addr here and value is " . $row->valx . "<br>\n";
//                               ff_setChecked('radio_btn',$row->valx);
//                               break;
         case 'cf_name'   : echo "Found Name and value is " . $row->valx . "<br>\n";
                               ff_setValue('cf_name', $row->valx); 
                               break;
         case 'cf_email'   : echo "Found Email and value is " . $row->valx . "<br>\n";
                               ff_setValue('cf_email', $row->valx); 
                               break;
         case 'cf_message'   : echo "Found Message and value is " . $row->valx . "<br>\n";
                               ff_setValue('cf_message', $row->valx); 
                               break;
         case 'cf_deelnemer'   : echo "Found Deelnemer and value is " . $row->valx . "<br>\n";
                               ff_setValue('cf_deelnemer', $row->valx); 
                               break;
         case 'cf_emaildeelnemer'   : echo "Found Emaildeelnemer and value is " . $row->valx . "<br>\n";
                               ff_setValue('cf_emaildeelnemer', $row->valx); 
                               break;
         case 'cf_bericht'   : echo "Found Bericht and value is " . $row->valx . "<br>\n";
                               ff_setValue('cf_bericht', $row->valx); 
                               break;
                              
//         case 'Birth_month'  : echo "Found Birth Month and value is " . $row->valx . "<br>\n";
//                               ff_setSelected('select_list', $row->valx);
//                               break;
//         case 'best_time_cm' : echo "Found best_time here and value is " . $row->valx . "<br>\n";
//                               ff_setChecked('check_box',$row->valx);
//                               break;

         default             : break;
       } // switch  
    }//for

    }
// }
  • Beeethoven
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
  • Page:
  • 1
Moderators: TheMuffinMan, ForumSupport
Time to create page: 0.23 seconds

Facebook Discount - 40% Off!

Fans of our Facebook page here are entitled to get a 1-year-subscription for the price of a 6-months!

Steps to take:

  • Become a fan on Facebook (Like) here
  • Purchase a 6-months-subscription from here
  • Write a quick email to This email address is being protected from spambots. You need JavaScript enabled to view it. with your username and prove of your like and we'll upgrade to the 1-year-subscription

Joomla!® Forms Discount - 40% Off!

Already purchased a forms extension from a different vendor but your requirements changed and now you need a forms extension that is capable of more than just the standards? We help you to keep the costs for a change under control: Get a 40% discount on our professional membership plan! -- meaning timely unlimited access to all current and future commercial extensions, breezingforms themes & apps and Joomla!® templates at crosstec.de, including 1 year of support -- without any website limitations -- Just prove that you previously purchased another forms extension for Joomla!® from a different vendor and you are qualified.

Steps to take:

  • Purchase a 1-year-subscription from here
  • Write a quick email to This email address is being protected from spambots. You need JavaScript enabled to view it. with your username and prove of the purchase for the other form vendor and we'll upgrade to the professional-subscription

About

Crosstec GmbH & Co. KG

Bergisch-Gladbacher-Str. 829

51069 Cologne, Germany

Imprint