Jump to content

Jriker1

New Members
  • Posts

    8
  • Joined

  • Last visited

Jriker1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Figured out a "way" to do it. Since I'm using PHP, if I know the there will be only one table, I can redefine the media queries in the body of the page output as long as it comes before those styles are used. Which it does.
  2. I have a website that has multiple views based on three items: Desktop Phone Tablet I use media queries to adjust the widths of content. Here's my problem. Page is PHP and you can pass &showone=1 as part of the URL to only show one table. With two tables looks like this: Text is perfectly centered over tables but as you can see, tables are left justified and space on the right. Normally title would center in the middle of the right table due to centering on the "page". I did this basically hard coded thru media queries so: /* desktop */ @media only screen and (min-width : 1224px) { th { font-size: 1.6em; font-family:Sans-serif; } td { font-size: 1.65em; line-height: 1em; font-family:Sans-serif;} h1 { font-size: 1.75em; line-height: 1.5em; } h2 { font-size: 1.25em; } table { width: 500px; align: left; } .centering {width: 1020px; padding-top:5px; border:0; margin-top:2px; text-align: center; font-size: 1.6em; font-family: Sans-serif; font-weight:bold;} } The .centering being passed using echo "<p class='centering'>Pool Mining: " . strtoupper($obj['multiport']['mining']) . "</p>"; Now if someone says they only want one table I get: See the problem then? The centering doesn't move over the first table as that's the only element left. Didn't expect it would the way it's setup. I can't figure an easy way based on the dynamic nature of the content, to tweak the placement of the titles based on the total content. I also have this issue with iPad in landscape mode. Ipad and iPhone in portrait mode the tables reorientate under each other so one table or two space us across is the same. Thoughts on how to get this to work? Tried doing a div with inline-block but it causes the second table to go under the first line all the time. Oddly tab on IE to another tab and tab back they were side-by-side again but not really a working solution and all other devices that didn't work at all. Thoughts? Thanks.
  3. This is what I ended up doing, not sure if it's the cleanest way or not. echo "Workers:<br><table>"; foreach ($obj['workers'] as $key => $vals) { foreach ($vals as $name => $wrk) { if ($wrk['hashrate'] != "0" ) { echo "<tr><td>" . $key . "</td>"; echo "<td>" . $name . "</td>"; echo "<td>" . $wrk['hashrate'] . "</td></tr>"; if (isset($workersArray[$name])) { $workersArray[$name] = $workersArray[$name] + $wrk['hashrate']; } else { $workersArray[$name] = $wrk['hashrate']; } } } } echo "</table>"; So placed the isset check and settings in it.
  4. I have an array from JSON that contains the below values. If you see the below (first code block), the second item in each line has commonality in a lot of cases with the wdc values further down. I am trying to create a single array that has only one of each second value in it (don't care about ftc or wdc), and a sum of the common entries. Could be two, three, four entries with the same name. So for the below, looking to get: jsob.5970, 1116 jsob.5970cpu, 7 jsob.5970two, 925 and so on. Basically adding like values together and creating a list of how much that item is doing total at any time as the list is dynamically refreshed whenever I refresh the json call (browser refresh). ftc, jsob.5970, 370 ftc, jsob.5970cpu, 7 ftc, jsob.5970two, 427 ftc, jsob.5970twocpu, 7 ftc, jsob.69597950, 320 ftc, jsob.An1cpu, 14 wdc, jsob.5970, 746 wdc, jsob.5970two, 498 wdc, jsob.69597950, 142 wdc, jsob.An1cpu, 14 wdc, jsob.An3cpu, 7 Thoughts? Was going to loop thru putting each item in a new array and if I hit an item that was already in the array add the new number to it, but figured my code would have been convoluted and there is probably an elegant way I don't know of yet to accomplish this. For reference the code to output the above (not with commas that's just for reference), is below: echo "Workers:<br><table>"; foreach ($obj['workers'] as $key => $vals) { foreach ($vals as $name => $wrk) { if ($wrk['hashrate'] != "0" ) { echo "<tr><td>" . $key . "</td>"; echo "<td>" . $name . "</td>"; echo "<td>" . $wrk['hashrate'] . "</td></tr>"; } } } echo "</table>"; Thanks.
  5. As another follow-up what if it goes one level deeper? So want to output a table like: LTC: jbod.5970: 20 LTC: jbod.5970cpu: 30 NVC: jbod.5970: 50 NVC: jbod.5970cpu: 0 NVC: jbod.5970two: 0 "workers": { "ltc": { "jbod.5970": { "hashrate":"20" }, "jbod.5970cpu": { "hashrate":"30" }, }, "nvc": { "jbod.5970": { "hashrate":"50" }, "jbod.5970cpu": { "hashrate":"0" }, "jbod.5970two": { "hashrate":"0" }, } } Thanks. Hoping this will give me that ahh ha moment and all will become clear. Thanks.
  6. 0down votefavorite I have some json that would like to parse thru without hardcoding the subvalues so others than me can use this as well. Example of the JSON is: {"payout_history":"0", "round_shares":"1816", "workers": { "jbo.5970": { "alive":"1", "hashrate":"1253" }, "jbo.5970cpu": { "alive":"1", "hashrate":"21" }, "jbo.5970-2": { "alive":"1", "hashrate":"1062" } } } So those jbo level items I can directly access by ['workers']['jbo.5970'] however tried like ['workers][0] but nothing was returned. Want to parse thru all the items under workers and then process the array elements in each jbo value. The jbo.* values are just examples, they could be anything so not static. Thoughts? UPDATED INFO: Using the below, I can get the alive and hash rate status of each worker which I am surprised about as I thought it was one level deeper than I'm going to get them. But I can not get the name of the worker itself. Basically want to output the worker name itself, then if alive and how fast it's hashrate is. $wemineltc = file_get_contents("http://localhost/wemineltc.json"); $obj=json_decode($wemineltc,true); foreach ($obj['workers'] as $wrk) { echo $wrk['alive'] . "<br>"; echo $wrk['hashrate'] . "<br>"; } I can also do like $obj['workers']['jbo.5970']['alive'] to get status of a particular worker, however as mentioned I am assuming the workers name is dynamic. Here is an example URL by the way: https://www.wemineltc.com/api?api_key=6fd24db2b31d3982ad5520c009588efe81b1b4cc07e9fcd7904d04434405e3ef Thanks. JR
  7. I tried doing like Foreach ($obj['report'] as $rep) { Echo $rep['immatureBalance']; } But it returns nothing. I know putting in a dummy echo statement shows is looing thru but nothing outputs. Am I at the wrong level? Thanks.
  8. I am trying to parse some JSON but it seems improperly formed but I'm an amateur at json. Trying to take http://middlecoin.com/json and get the values under a particular ID. for example 17GLRCLFRRue4NcV5mq7pGtRgLsTPhQBNB. Sample below. Any help would be appreciated { "totalPaidOut": "707.11990563", "totalRejectedMegahashesPerSecond": "68.5536", "totalImmatureBalance": "26.09407515", "totalMegahashesPerSecond": "1128.4542", "totalBalance": "28.64664489", "time": "2013-08-25 00:01:00", "report": [ [ "1PqM7xBPA6Q2DohamzncBGY48U17jC9tVA", { "lastHourShares": 7832, "immatureBalance": "1.98299637", "lastHourRejectedShares": 237, "paidOut": "77.12863943", "unexchangedBalance": "0.35186175", "megahashesPerSecond": "72.9995", "bitcoinBalance": "1.58811717", "rejectedMegahashesPerSecond": "2.2090" } ], [ "17GLRCLFRRue4NcV5mq7pGtRgLsTPhQBNB", { "lastHourShares": 7777, "immatureBalance": "1.94445547", "lastHourRejectedShares": 442, "paidOut": "23.71529615", "unexchangedBalance": "0.46860515", "megahashesPerSecond": "72.4869", "bitcoinBalance": "1.64996171", "rejectedMegahashesPerSecond": "4.1197" } Thanks. JR
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.