Advertisement
Guest User

Example of json eve

a guest
Jul 11th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2. //--------------------
  3.   // Gets JSON file
  4.   $json = file_get_contents("adam/marketdata3.json"); // read file , is json type
  5.   //die (htmlentities($json));
  6.   $r=json_decode($json,true); // convert json to array
  7.   /*  echo "<hr><pre>";
  8.     print_r($r);
  9.     echo "</pre><hr>";
  10.     */  
  11.    
  12.     $numbers=explode(",",$cadena); // split item numbers to array
  13.     foreach ($numbers as $item){ // walk array of number item, for prices
  14.    
  15.     //$item=20; // exmple
  16.     // directly read in array of that item,m this is the magic
  17.        $buyavg= $r[$item][buy][percentile];
  18.        $sellavg= $r[$item][sell][percentile];  
  19.        $sql="update EVE_PRICES set BUY=$buyavg,SELL=$sellavg where ITEMID='$item'";
  20.       //echo "<li>$sql";
  21. if ($buyavg=="" and $sellavg==''){
  22.     echo "Nobody selling item $item: ".description($item);
  23.     $buyavg=0;
  24.     $sellavg=0;
  25.   }
  26.   $sql="update EVE_PRICES set BUY=$buyavg,SELL=$sellavg where ITEMID='$item'";
  27.   mysql_query($sql) or die ("error 1231b:" .mysql_error()."<hr>$sql");
  28.   } // each
  29.    //}    
  30.      
  31.     //--------------
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement