Skip to main content
removed code to not give away my solutions future students
Source Link
Jesse
  • 157
  • 3
  • 17
            <div class="panel panel-default">
            <div class="panel-heading">Portfolio</div>

                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>Symbol</th>
                            <th>Name</th>
                            <th>Shares</th>
                            <th>Price</th>
                            <th>TOTAL</th>
                        </tr>
                    </thead>
                    <tbody> 
                        <?php foreach ($positions as $position)EDIT: ?> 
                        <?php $total = $position["shares"] * $position["price"]; ?>
                        <tr>
                            <td><?= $position["symbol"] ?></td>
                            <td><?= $position["name"] ?></td>
                            <td><?= $position["shares"] ?></td>
                            <td>$<?= number_format($position["price"], $decimals = 2); ?></td>
                            <td>$<?= number_format($total, $decimals = 2); ?></td>
                        </tr> 
                        <?php endforeach ?>
                    
                        <tr>
                            <td colspan="4">CASH</td>
                            <td>$<?= number_format($money, $decimals = 2) ?></td>
                        </tr>    
                    </tbody>
                </table>
       Removed </div>code
            <div class="panel panel-default">
            <div class="panel-heading">Portfolio</div>

                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>Symbol</th>
                            <th>Name</th>
                            <th>Shares</th>
                            <th>Price</th>
                            <th>TOTAL</th>
                        </tr>
                    </thead>
                    <tbody> 
                        <?php foreach ($positions as $position): ?> 
                        <?php $total = $position["shares"] * $position["price"]; ?>
                        <tr>
                            <td><?= $position["symbol"] ?></td>
                            <td><?= $position["name"] ?></td>
                            <td><?= $position["shares"] ?></td>
                            <td>$<?= number_format($position["price"], $decimals = 2); ?></td>
                            <td>$<?= number_format($total, $decimals = 2); ?></td>
                        </tr> 
                        <?php endforeach ?>
                    
                        <tr>
                            <td colspan="4">CASH</td>
                            <td>$<?= number_format($money, $decimals = 2) ?></td>
                        </tr>    
                    </tbody>
                </table>
        </div>
EDIT: Removed code
Source Link
Jesse
  • 157
  • 3
  • 17

Table layout portfolio

So I'm working on my portfolio, but I can't get my table nicely lined up.

How can I fix this with my html/css/php code? (code down below)

portfolio

            <div class="panel panel-default">
            <div class="panel-heading">Portfolio</div>

                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>Symbol</th>
                            <th>Name</th>
                            <th>Shares</th>
                            <th>Price</th>
                            <th>TOTAL</th>
                        </tr>
                    </thead>
                    <tbody> 
                        <?php foreach ($positions as $position): ?> 
                        <?php $total = $position["shares"] * $position["price"]; ?>
                        <tr>
                            <td><?= $position["symbol"] ?></td>
                            <td><?= $position["name"] ?></td>
                            <td><?= $position["shares"] ?></td>
                            <td>$<?= number_format($position["price"], $decimals = 2); ?></td>
                            <td>$<?= number_format($total, $decimals = 2); ?></td>
                        </tr> 
                        <?php endforeach ?>
                    
                        <tr>
                            <td colspan="4">CASH</td>
                            <td>$<?= number_format($money, $decimals = 2) ?></td>
                        </tr>    
                    </tbody>
                </table>
        </div>