Begini, saya lagi belajar memahami PHP secara detail dan saya memiliki masalah saat ingin melakukan edit dimana terjadi error.
Notice: Undefined index: id_data in C:\xampp\htdocs\index\menampilkandata\table\edit.php on line 3
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\index\menampilkandata\table\edit.php on line 4
Untuk Primary Key saya menggunakan Field id_data
Berikut Source yang saya gunakan
Lihat.php<style rel='stylesheet' type='text/css'>
th{
background:#1d87eb;
text-align: center;
font-type: bold;
border: 0px red;
}
tr{
background:#e6e6e6;
text-align:center;
border: 0px;
}
</style>
<table>
<form method='post' action='hapus.php'>
<tr><th>No.</th><th>Nama</th><th>Alamat</th><th>JK</th><th>Hapus</th><th>Ubah</th></tr>
<?php
//Koneksi Ke Database
include "config.php";
$tampil = mysql_query("SELECT * FROM data ORDER BY id_data");
$no = 1;
while ($data = mysql_fetch_array($tampil)){
echo"<tr>
<td>$no</td>
<td>$data[nama]</td>
<td>$data[alamat]</td>
<td>$data[jk]</td>
<td><a href='edit.php?=$data[id_data]'>Edit</a></td>
<td><input type='checkbox' name=cek[] value='$data[id_data]>'</td>
</tr>
";
$no++;
}
echo "<tr><td colspan=6 align=center><input type=submit value=Hapus /><INPUT TYPE='BUTTON' VALUE='Tambah' ONCLICK=window.location.href='tambah.php'></td></tr></form></table>";
?>
Edit.php<?php
$id_data = $_GET['id_data'];
$data = mysql_fetch_array(mysql_query("SELECT * FROM data WHERE id_data='$id_data'"));
echo"
<table width='303' border='1'>
<form method='post' action='input.php' >
<tr>
<td width='142'>Nama</td>
<td width='145'><input name='nama' type='text' value='$data[nama]' ></td>
</tr>
<tr>
<td>Alamat</td>
<td><input name='alamat' type='text' value='$data[alamat]' ></td>
</tr>
<tr>
<td>Jenis Kelamin</td>
<td><select name='jk' value='$data[jk]'>
<option value='L'>Laki - Laki</option>
<option value='P'>Perempuan</option>
</select>
</td>
</tr>
<tr><td colspan='2' align='center'><input type='submit' value='Submit'></td></tr>
</form>
</table>
";
?>
Kira² Kesalahannya dimana, sehingga terjadi error seperti di atas