OKIEWARDOYO

PHP MYSQL No.10 - fungsi saveBlock

Aug 27th, 2012
2,570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.91 KB | None | 0 0
  1. //function to save position
  2. function saveBlock(){
  3.     $data = $_POST;
  4.     //print_r($data);
  5.     foreach($data as $key => $value){
  6.         foreach($value as $key2 => $value2){
  7.             $item = explode("_",$value2['id']); //split item_3 to get 3 and that is our item table id
  8.             $value2['id'] = $item[1];
  9.  
  10.             $col = explode("_", $value2['column']); //split
  11.             $value2['column'] = $col[1];
  12.  
  13.             ///
  14.            
  15.             $new_column = $value2['column'];
  16.             $new_order = $value2['order'];
  17.             $id = $value2['id'];
  18.  
  19.             $query = "UPDATE `metu_builder` SET `column`='$new_column', `order`='$new_order' WHERE `ID`='$id'";
  20.             if(mysql_query($query))
  21.                 continue;
  22.             else{
  23.                 echo 'Error query';
  24.                 exit();
  25.             }
  26.            
  27.         }
  28.     }
  29.     return 'Saved successfully';
  30. }
Advertisement
Add Comment
Please, Sign In to add comment