Welcome, Guest

INSERT query UPDATE?
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: INSERT query UPDATE?

INSERT query UPDATE? 3 years, 7 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.28 seconds

About

Crosstec GmbH & Co. KG

Bergisch-Gladbacher-Str. 829

51069 Cologne, Germany