top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to display the last record of the field in a input box using PHP?

0 votes
603 views

I have php script form which I used to input Members Details of my system into the MySQL database. My requirement is to display the last member's details in a input box.

posted Apr 17, 2017 by Kavyashree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

Get your last record as follows -

SELECT * FROM your_table ORDER BY your_auto_increment_field DESC LIMIT 1; 

and just display it...

answer Apr 19, 2017 by Salil Agrawal
0 votes

Hi,

You can find your last record using following query:

SELECT * FROM table_name  ORDER BY  primarykeyid DESC LIMIT 1;

Hope this answer will help you

answer Oct 2, 2019 by Siddhi Patel
Similar Questions
+2 votes

I have a date field on an html form that users may leave blank. If they do leave it blank I want to write the date 01/01/1901 into the mysql table. How can I accomplish this and where in my .php script file should I put the code?

–1 vote

I want to update my sql database record and want to populate the value of previous record. So anybody can help me to get the previous value of the record to show when the update require.

+1 vote

I am tring to create a new table into the database if the table name given is not present in database using Php .
This is the code that I am using .

  $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if(!$conn)
    {
            die('Failed to connect to server: ' . mysql_error());
            exit;
    }
    $db_selected = mysql_select_db($dbname);
    if(!$db_selected)
    {
           $db_selected = " CREATE DATABASE $dbname ";
    }
    $usertb1 = mysql_query("select 1 from $usertb LIMIT 1");
    if( $usertb1 !== FALSE )
    {
           $sql = "CREATE TABLE IF NOT EXISTS $usertb ( uid INT(20) AUTO_INCREMENT UNIQUE KEY NOT NULL,name VARCHAR(40),email varchar(40) PRIMARY KEY NOT NULL)";
    }
    $typetb1 = mysql_query("select 1 from $typetb LIMIT 1");
    if( $typetb1 !== FALSE)
    {
           $sql1 = "CREATE TABLE IF NOT EXISTS $typetb( uid INT(20) NOT NULL, type ENUM('WEB','APP','CART') NOT NULL ,unsubscribe TINYINT(1) NOT NULL,bounce TINYINT(1) NOT NULL,complaint TINYINT(1) NOT NULL, PRIMARY KEY (uid,type), FOREIGN KEY(uid) WHERE promo_user(uid))";
    }
...