Created
January 30, 2018 02:08
-
-
Save malikkurosaki/8e483843e79b6c0d86cf5cb2644c4cb7 to your computer and use it in GitHub Desktop.
this example code for get last id in db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$host = "127.0.0.1:3306"; | |
$user = "root"; | |
$pass = ""; | |
$db = "malikdata"; | |
$line = new mysqli($host,$user,$pass,$db); | |
if($line->connect_error){ | |
echo "<br>connection error".$line->connect_error; | |
}else{ | |
echo "connection succsesfuly<br>"; | |
} | |
$sql = "INSERT INTO halaman(judul,content)VALUES('halaman tiga','ini content halaman dua agak panjang tapi tidak mengapa lah bisa dibaca yang penting soalnya masih baru nyoba gitu')"; | |
if($line->query($sql) === TRUE){ | |
$last_id = $line->insert_id; | |
echo "berhasil memasukkan data<br>".$last_id; | |
}else{ | |
echo "error".$sql."koneksi".$line->error; | |
} | |
$line->close(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment