I've struck this problem, and I just can't solve it. I've come a long way with all the maths behind the table and the table being put out as a result of a function behind the shortcode. Then I also managed to make the table variable by using the attributes assigned to a shortcode. But what would complete my function is the ability to pass several inputs to the same shortcode and those inputs forming a nice table. I've tried using several shortcodes, but better would be if everything could be fit into one shortcode. It's probably a little vague now, let me clear things up by supplying some code.
function test( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'investment' => '1',
'coinamount' => '0.5',
'coin' => 'BTC',
'currency' => 'EUR',
),
$atts,
'investment'
);
//Declaring all my variables
$coinworth = get_coin_worth($atts['coin'], $atts['currency']);
$currencyworth = get_currency_worth($atts['coin'], $atts['currency']);
$coinname = get_coin_name($atts['coin']);
$currencyname = get_currency_name($atts['currency']);
$investment = $atts['investment'];
$coinamount = $atts['coinamount'];
$portfolioworth = $coinamount*$coinworth;
$result = $portfolioworth - $investment;
$result = number_format((float)$result, 2, '.', '');
//Creating the table
$table = <<<EOD
<h1 style="text-align:center">Uw Portfolio</h1>
<table style="width:100%">
<tr>
<th>Invested Currency</th>
<th>Investment Worth</th>
<th>Coin amount</th>
<th>Recent Portfolioworth</th>
<th>Result</th>
</tr>
<tr>
<td>$currencyname</td>
<td>$investment</td>
<td>$coinamount</td>
<td>$coinworth</td>
<td $style$result</td>
</tr>
</table>
EOD;
return $table;
}
As you can see, it's a pretty big function, take some time to understand it. Now, I've seen this post, but as you see I have multiple data inputs for every row and I just can't grasp how to combine them all the way i'm doing right now.
Anyone any idea? You will be helping me loads!
Kind regards