Last ID shown

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
fciprian
Veteran Member
Posts: 52
Joined: 2020-04-20 10:51

Last ID shown

Post by fciprian » 2020-05-07 15:38

Hello.
I need to hide all rows from a table. but i need to show a text ONLY the last raw added!
How can i do that? under the serch console to have " The last row was insered on $id"

Thank you verry much.
I apriciate your help. It is helping me a lot!

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: Last ID shown

Post by patsd102 » 2020-05-07 16:33

This will select 1 row.
I used an iframe to add it to my site

Change to suite your database and fields

Code: Select all

<body>
<i>To post a message, Click the "Shout" button </i><p></p></p>

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "databasename";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT field1, field2, field3 FROM tablename ORDER by `id` DESC LIMIT 0, 1";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
<div class="container">    echo "<table><tr><th>1 row</th><th>2 row</th><th>3 row</th></tr>";
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "<tr><td>" . $row["field1"]. "</td><td>" . $row["field2"]. "</td><td>" . $row["field3"]. "</td></tr>";
    }
    echo "</table></div>";
} else {
    echo "0 results";
}

$conn->close();
?>

</body>
23.17

Post Reply