Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbhost="localhost";
- $dbuser="root";
- $dbpasw="";
- $dbname="latihan";
- $link=mysql_connect($dbhost,$dbuser,$dbpasw);
- mysql_select_db($dbname,$link);
- function delete_row($table,$field,$value){
- $sql="DELETE FROM $table WHERE $field='$value'";
- $ret=mysql_query($sql);
- return $ret;
- }
- if(!empty($_GET['id'])){
- delete_row('prodi','kd_prodi',$_GET['id']);
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Latihan Fungsi Delete Baris</title>
- </head>
- <body>
- <table width="200" border="1">
- <tr>
- <td>Prodi</td>
- <td>Nama</td>
- <td>Delete</td>
- </tr>
- <?php
- while($k=mysql_fetch_array($q)){
- echo "<tr>\n";
- echo "<td>".$k['kd_prodi']."</td>\n";
- echo "<td>".$k['prodi']."</td>\n";
- echo "<td><a href=\"".$SERVER['PHP_SELF']."?id=".$k['kd_prodi']."\">hapus</a></td>\n";
- echo "</tr>\n";
- };
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement