i have a table in mysql with 2 fields (num and name)
i need to insert lots of names and each name has one number like the example below
i need php in "page 2" to insert next number after the last one (in this case, number 5) if i insert only the name and leave the number txt empty, in other words, i need it to be with default text inside, but this text is the last number in the table (in this case, number 5).
1 - john
2 - maria
3 - monica
4 - george
page 1 form_page.html
<form action="add.php" method="post">
<input type="text" name="txt_num">
<input type="text" name="txt_name">
<input type="submit">
</form>
page 2 add.php
<?php
include('connect_db.php');
$sql="INSERT INTO(
num,
name,
)
VALUES(
'$_POST[txt_num]',
'$_POST[txt_name]',
)";
?>
page 3 connect_db.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "database_name";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("<p2>Database connection failed: </p2>" . mysqli_connect_error());
}
?>