Data from SQL in alphabetical order
Posted: 11 Jan 2021, 16:16
Plessant Coursesweb,
I have an grouplist in my database from country`s.
First time I did not do any search-study for this questionm but ask you straitly....
I would like to have my list in alphabetical order.
Can this be easely done into this code ?
I have an grouplist in my database from country`s.
First time I did not do any search-study for this questionm but ask you straitly....
I would like to have my list in alphabetical order.
Can this be easely done into this code ?
Code: Select all
<?php
// connect to the "tests" database
$conn = new mysqli('127.0.0.1', 'comments', '123456', 'comments');
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// SELECT sql query
$sql = "SELECT * FROM `w3_post` where group_id='40' ORDER BY `w3_post`.`post_id` DESC";
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
// output data of each row from $result
while($row = $result->fetch_assoc()) {
echo '
'. $row['title']. ' <br><br> ' ;
}
}
else {
echo ' okkok';
}
$conn->close();
?>