Sort coins in json file?

hello i am just wondering how would i do a faucet list with 11 coins in json

i keep rethinking this over would i need to create 1 lot off files like for the header and footer with its own title video description etc
and create other 1 lot off files for the faucet website and rewards and minutes and owners name etc?

So I’m not sure why you’ve posted this in PHP, it’s probably better off in the Javascript section, unless i’m not understanding the question.

What exactly do you want to… do? What information are you trying to store? or sort?

You say you know you can do it in mysql. JSON can be used the same way as a mysql table, just written to a single file…

oh javascript opps

i will put it in simple words

i would like to store the 11 coins in a list so it has its own pages and titles video etc

yes i did said that i know how to do it in mysql coz i seen other script

like this image

Well a JSON object for the structure presented in the picture might look something like…

[{"name": "Bitcoin",
  "shorthand": "BTC",
  "value": 9284.97,
  "cap": 156...thatbignumberimnottyping,
  "change": 13.18,
  "faucets": [
        {"name":"gr8 Faucet",
         "currency": "BTC",
        "payment": "Faucethub",
        "reward": "~3000",
        "info": "<p> This is some stuff that probably pops up in a window to tell you about the thing.</p>",
        "link": "http://gr8faucet.net"},
        //Next Faucet goes here...
   ]
   },
   {"name": "ETHcoin",
  "shorthand": "ETH",
  "value": 56.97,
  "cap": 90,
  "change": 63.12,
  "faucets": [
        {"name":"EL Faucet",
         "currency": "ETH",
        "payment": "Faucetplace.EU",
        "reward": ">9000",
        "info": "<p> This place is really great. I think..</p>",
        "link": "http://notarealplace.void"},
        {"name":"gr8 Faucet",
         "currency": "ETH",
        "payment": "Faucethub",
        "reward": "~3",
        "info": "<p> This is some stuff that probably pops up in a window to tell you about the thing.</p>",
        "link": "http://gr8faucet.net"}
    ]
 }
]  

I’m still not entirely sure what question you’re asking though.

this is right now how would i display it in html

coz i am trying to make a non mysql faucet list just with json data so then in the admin panel . they can delete or edit the stuff

Since the question started in PHP, i assume you’re using that to manipulate your data.

$jsondata = file_get_contents('myjson.json');
$jsonarray = json_decode($jsondata,true);

And then the data is in an array, for you to manipulate and output as you wish.

i mean how would i display it in datatable if its not to much to ask could you give me 1 example

and thank You for your help

The same way you display it if it was a mysql result. Find the record you want

$filteredarray = array_filter($jsonarray,function($currency) use ($TheOneImLookingFor) { return $currency['currency'] == $TheOneImLookingFor; }

, and then

foreach($filteredarray[0]['faucets'] as $faucet ) { //Do Some code with $faucet. } 

Beyond that is up to you.

The logic for getting values into well-formed mark-up can be a bit tricky. The more deeply nested the mark-up, the trickier it can be. Just need to think it through slowly and carefully and check to see it’s correct. i.e.

  • make sure there is tabular data to display
  • generate opening table tag
    • make sure there is a row to display
    • loop through rows
    • generate opening row tag
      • make sure there is a cell to display
      • generate opening cell tag
      • populate it with the value
      • generate closing cell tag - continue loop until end of row’s cell data
    • generate closing row tag - continue loop until end of table’s row data
  • generate closing table tag

It can be more complex than that, say if you want thead and tfoot, but that’s the idea

mysqli stuff is easy you can look it up

thanks for your help anyway

to hard thats why i asked for a example i am just learning it

i will just keep searching the internet until i find a working example

thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.