Contoh script php edit data MySQL disimpan dengan nama editbarang.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
<?php // emerer.com $KodeBarang= $_GET[KodeBarang]; // tentukan nama tabel dan database $db_name = "dbmrr"; $table_name = "barang"; //koneksi ke server dan pilihdatabase $connection = @mysql_connect("localhost" , "root" , "" ) or die (mysql_error()); $db = @mysql_select_db ($db_name, $connection ) or die (mysql_error()); //membangun query $sql= "select KodeBarang, NamaBarang, Satuan, Qty from $table_name where KodeBarang ='$KodeBarang'"; $result = @mysql_query($sql,$connection) or die (mysql_error()); // buat daftar hasil yang ditemukan while($row = mysql_fetch_array($result)) { $KodeBarang= $row['KodeBarang']; $NamaBarang = $row['NamaBarang']; $Satuan = $row['Satuan']; $Qty = $row['Qty']; } ?> <html> <head> <title>eMeReR.com | Muhammat Rasid Ridho</title> </head> <body> <table width="100%" height="100%" border="5"> <tr height="10%" bgcolor="lime"> <td colspan="2" align="center"> <?php // Memanggil header.php include ("header.php"); ?> </td> </tr> <tr height="80%" valign="top"> <td width="150" bgcolor="lime"> <?php // Memanggil menu.php include ("menu.php"); ?> </td> <td> <?php // ISI ?> <h3 align="center">Edit Barang</h3> <form method="post" action="updatebarang.php"> <table width="100%" height="100%"> <tr> <td>Kode Barang</td> <td><input readonly name="KodeBarang" type="text" value="<?php echo $KodeBarang ?>"/></td> </tr> <tr> <td>Nama Barang</td> <td><input name="NamaBarang" type="text" value="<?php echo $NamaBarang ?>"/></td> </tr> <tr> <td>Satuan</td> <td><input name="Satuan" type="text" value="<?php echo $Satuan ?>"/></td> </tr> <tr> <td>Quantity</td> <td><input name="Qty" type="text" value="<?php echo $Qty ?>"/></td> </tr> <tr> <td> </td> <td><input name="Submit1" type="submit" value="Update" /></td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </form> </td> </tr> <tr height="10%" bgcolor="lime"> <td colspan="2" align="center"> <?php // Memanggil footer.php include ("footer.php"); ?> </td> </tr> </table> </body> </html> |
Berikut ini merupakan file pendukung lainnya, silahkan coba file php di bawah ini.