Skip to content

Instantly share code, notes, and snippets.

@ErikThiart
Created August 1, 2018 18:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErikThiart/3d2cdae6f4cda612ff426db6565cf1a2 to your computer and use it in GitHub Desktop.
Save ErikThiart/3d2cdae6f4cda612ff426db6565cf1a2 to your computer and use it in GitHub Desktop.
Example: Re-write this using C# and WPF/WinForms
<?php
/*
* This pulls in the data from an external source
* This will probably be stored and retreived from a DB in real life
* See this piece of code as the C# code for the winform
*/
$json = file_get_contents('https://coindata.co.za/api.php');
$coins = json_decode($json);
?>
<!DOCTYPE html>
<!-- This will be the WinForm -->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Coin Prices!</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
<script defer src="https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
</head>
<body>
<section class="section">
<div class="container">
<h1 class="title">All Coins</h1>
<p class="subtitle">Display all the coins in a <strong>Desktop</strong> app</p>
<table class="table">
<thead>
<tr>
<th>Rank</th>
<th>Name</th>
<th>Price (USD)</th>
<th>1h %</th>
<th>24h %</th>
</tr>
</thead>
<tbody>
<?php foreach ($coins as $coin): ?>
<tr>
<th><?=$coin->Rank;?></th>
<th><?=$coin->Name;?>(<?=$coin->Symbol;?>)</th>
<th><?=$coin->USD_Price;?></th>
<th><?=number_format($coin->Change_1h, 2);?>%</th>
<th><?=number_format($coin->Change_24h, 2);?>%</th>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</section>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment