Group SQL results by date

Advertisements I’m having trouble splitting the results from a SQL query into dates. I have something like that: i have something like that And I want something like that: i want this // I use bootstrap… $result = $conn->query($sql); if ($result->num_rows > 0) { echo ‘<div class="list-group">’; while($row = $result->fetch_assoc()) { $newDate = date("d.m.Y", strtotime($row["dataczas"]));… Read More Group SQL results by date

Inconsistency of MySQL syntax errors depending on whether query made from command line or mysqli_connect

Advertisements A simple MySQL query is returning a syntax error over mysqli_connect, but the identical, copy-pasted query is successful in both the CLI and phpMyAdmin. Consider this example for MySQL 8.0: // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } $sql = "USE… Read More Inconsistency of MySQL syntax errors depending on whether query made from command line or mysqli_connect

Why is my table only showing the last row entered?

Advertisements I think the problem is in my loop. But I’m also checking my database. <table class="table"> <thead> <tr> <th scope="col">ID</th> <th scope="col">First Name</th> <th scope="col">Last Name</th> <th scope="col">Username</th> <th scope="col">Password</th> <th scope="col">Actions</th> </tr> </thead> <tbody> <?php $sql = "SELECT * from dbtest.tbluser"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of… Read More Why is my table only showing the last row entered?

how can i show multiple data in one string in php and mysql

Advertisements i have 2 tables in my database one called topics and the other called sections every topics has multiple sections and they linked to main topic by id for example this is my datable topics id title content sections id title topic_id i use this code to show content <?php $show_topics = $topics->select_topics($page); while… Read More how can i show multiple data in one string in php and mysql