I'm new to PHP. I try to build simple page with PHP and MySql, but failed to display the spesific data.
I try this: Get data from MySQL database by specific id in url to display data by "id_pemesanan" not "id" from the database.
But it's failed.
This is my code:
<?php
$id = $_GET['id_pemesanan'];
$mysqli = new mysqli("localhost", "root", "", "mad");
$query = "SELECT * FROM pesanan WHERE id_pemesanan ='". $id."'";
$result = $mysqli->query($query);
$row = $result->fetch_array(MYSQLI_BOTH);
{
echo "<p>$row[asal]</p>";
    }
?>
This is my database table structure:
CREATE TABLE `pesanan` (
  `id` int(11) NOT NULL,
  `id_pemesanan` int(11) NOT NULL,
  `pemesan` text NOT NULL,
  `asal` text NOT NULL,
  `lat` varchar(500) NOT NULL,
  `lng` varchar(500) NOT NULL,
  `tujuan` text NOT NULL,
  `lat_tujuan` varchar(500) NOT NULL,
  `long_tujuan` varchar(500) NOT NULL,
  `jarak` text NOT NULL
) ENGINE=MyISAM
I want display the spesific data using url like: http://localhost/mios/open/lengkap.php?=11772
The "11772" in the url is from "id_pemesanan"
I want the code to display the data. But, the error messages come.
Here the error massage:
Notice: Undefined index: id_pemesanan in 
C:\xampp\htdocs\mios\open\lengkap.php on line 2
 
     
     
     
     
    