product_edit.php
<?php
$result = mysql_query("SELECT * FROM produk AS p, kategori AS k WHERE id_produk='".$_REQUEST['id']. "', p.kategori_id = k.kategori_id") or die(mysql_error());
$data = mysql_fetch_array($result);
// cari syntax sql yang pas
//$result_kat = mysql_query("SELECT * FROM kategori WHERE id_produk=".$_REQUEST['id']) or die(mysql_error());
//$data_kat = mysql_fetch_array($result);
?>
<form method = "POST" enctype="multipart/formdata" action = "<?php $_SERVER['PHP_SELF'] ?>">
<table border="0" cellpadding="2">
<tr>
<td>Nama</td>
<td><input name="nama" type="text" value = <?php echo $data['nama_produk']; ?> size="20" />
</tr>
<tr>
<td>Kategori</td>
<td><select name=“select”>
<option value=“kategori”>Kategori</option></select></td>
</td>
</tr>
<tr>
<td>Harga</td>
<td><input name="harga" type="text" value = <?php echo $data['harga']; ?>></td>
</tr>
<tr>
<td>Deskripsi</td>
<td><textarea name="deskripsi" cols="30" rows="15" value = <?php echo $data['deskripsi']; ?></textarea>
<script type="text/javascript">
var editor = CKEDITOR.replace('deskripsi');
</script>
</td>
</tr>
<tr>
<td>Gambar</td>
<td><img src="foto_produk/<?php echo $data['gambar'];?>" width="30%" height="30%" /></td>
</tr>
<tr>
<td>Ganti Gambar</td>
<td>
<input name="uploaded_file" type="file" value="Browse" /></td>
</form>
</tr>
<tr>
<td></td>
<td><br /><center><input name="save" type="button" value="Simpan" /></center></td>
</tr>
</tr>
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' p.kategori_id = k.kategori_id' at line 1
What's wrong with SQL Syntax?
$result = mysql_query("SELECT * FROM produk AS p, kategori AS k WHERE id_produk='".$_REQUEST['id']. "', p.kategori_id = k.kategori_id") or die(mysql_error());
I am using this SQL syntax for my combo box in:
<td>Kategori</td>
<td><select name=“select”>
<option value=“kategori”>Kategori</option></select></td>
The category is in different table (kategori table) then the rest of the field (product table). I am trying to link the table by using kategori_id