I am totally new to web development. I am doing a personal project for learning purpose.
I have a php page, which query my database and return the data.
My query is :
SELECT * FROM myTable ORDER BY id;
That works fine from a SQL GUI tool.
When I load my page, the data is not ordered by the ID. Each time I refresh the page, the order is randomly changed.
My HTML header section
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js"></script>
<script>window.jQuery || document.write('<script src="/js/jquery-1.12.4.min.js">\x3C/script>')</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
My loadData.php page
try {
$connection = new PDO($dsn, $username, $password, $options);
$sqlData = "SELECT * FROM cc_data_tbl where cc_uuid = '" . $_GET['load_uuid'];
$statement = $connection->query($sqlData);
$results = $statement->fetchAll(PDO::FETCH_ASSOC);
if ($statement->rowCount() == 0){
echo "No Data";
} else { ?>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header clearfix">
<?php
echo "<table class='table table-bordered table-striped' id=\"transactionList\">";
echo "<thead>";
echo "<tr>";
echo "<th>Transaction Date</th>";
echo "<th>Listing Date</th>";
echo "<th>Description</th>";
echo "<th>Amount</th>";
echo "<th>Category</th>";
echo "<th>Category Type</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
foreach($results as $row){
echo "<tr>";
echo "<td>" . $row['cc_transac_date'] . "</td>";
echo "<td>" . $row['cc_listing_date'] . "</td>";
echo "<td>" . $row['cc_description'] . "</td>";
echo "<td>" . $row['cc_amount'] . "</td>";
echo "<td>" . $row['cc_category'] . "</td>";
echo "<td>" . $row["cc_category_type"] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
?>
</div>
</div>
</div>
</div>
</div>
<?php }
} catch (PDOException $error) {
echo $error -> getMessage();
}
I was expecting to have my data sorted by ID, which is not the case. This is a rather really basic SQL query... so I assume there's something that I really do not understand with HTML / PHP / Bootstrap as all these things are new to me.