Advertisement
remymumoh

Untitled

Sep 20th, 2020
988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. <?php
  2. $MyData=$_REQUEST['pass'];
  3.  
  4.  
  5.  
  6.  include('Connectoperations.php');
  7.     function Check_DoIn($table,$ID)
  8.     {
  9.         var_dump($table, $ID);
  10.         $json=singleval($table,'ID','',"Where ID=".$ID,'');  
  11.         var_dump($json);   
  12.         $myjson = json_decode($json, TRUE);
  13.         if ($myjson["ID"]=="")  
  14.  
  15.             //is not in do an insert
  16.             return 0;
  17.         else
  18.             //is in do an update
  19.             return 1;
  20.     }
  21.  
  22.     $passingJson=$MyData;
  23.     //echo $passingJson;
  24.     $myjsoncheck = json_decode($passingJson, TRUE);
  25.     // echo $myjsoncheck["Table"];
  26.     if (sizeof( $myjsoncheck['results'])>0){
  27.        
  28.         $Mytable=$myjsoncheck["Table"];
  29.         $Messagein=$myjsoncheck["message"];
  30.        
  31.         foreach ($myjsoncheck['results'] as $f)  
  32.         {       //echo $Mytable;
  33.             if (Check_DoIn($Mytable,$f["ID"])==0)
  34.             {
  35.             //echo "Doinsert";
  36.                 $MyAttributes="";
  37.                 $MyValues="";
  38.                 $MyWhere='Where ID='.$f["ID"];
  39.                 //Get the table attributes and values
  40.                 foreach($f as $key => $value)
  41.                 {
  42.                     $MyAttributes=$MyAttributes ."," . $key;
  43.                     $MyValues=$MyValues . ',"'.$value.'"';
  44.                 }
  45.                 $MyAttributes =substr($MyAttributes,1);
  46.                 $MyValues =substr($MyValues,1);
  47.                 echo insert($Mytable,$MyAttributes,$MyValues,"",$Messagein);
  48.            
  49.            
  50.             }else
  51.             {
  52.                 //echo ",DoUpdate";  
  53.                 echo  updateJson($f,$Mytable,$Messagein);
  54.             }
  55.          
  56.                        
  57.          }
  58.      }
  59.  
  60. ?>
  61.  
  62.  
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement