Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require_once('Connections/connection.php'); ?>
- <?php
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
- {
- $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
- switch ($theType) {
- case "text":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "long":
- case "int":
- $theValue = ($theValue != "") ? intval($theValue) : "NULL";
- break;
- case "double":
- $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
- break;
- case "date":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "defined":
- $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
- break;
- }
- return $theValue;
- }
- $editFormAction = $_SERVER['PHP_SELF'];
- if (isset($_SERVER['QUERY_STRING'])) {
- $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
- }
- if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
- $updateSQL = sprintf("UPDATE peserta SET nama=%s,nokp=%s, jantina=%s, kelas=%s WHERE idpeserta=%s",
- GetSQLValueString($_POST['namapeserta'], "text"),
- GetSQLValueString($_POST['nokp'], "text"),
- GetSQLValueString($_POST['jantina'], "text"),
- GetSQLValueString($_POST['idkelas'], "text"),
- GetSQLValueString($_POST['idpeserta'], "text"));
- mysql_select_db($database_connection, $connection);
- $Result1 = mysql_query($updateSQL, $connection) or die(mysql_error());
- if (isset($_SERVER['QUERY_STRING']))
- {
- echo "<script>alert('Record updated.')</script>";
- $GoTo = "paparpeserta.php";
- echo "<meta http-equiv='refresh' content='0;url=$GoTo'>";
- }
- }
- if (isset($_GET['idpeserta']))
- {
- $id = $_GET['idpeserta'];
- mysql_select_db($database_connection, $connection);
- $query_q_editpeserta = "SELECT peserta.idpeserta, peserta.nama, peserta.nokp, peserta.kelas, peserta.jantina, kelas.namakelas
- FROM peserta
- INNER JOIN kelas ON peserta.kelas = kelas.idkelas where peserta.idpeserta= $id";
- $q_editpeserta = mysql_query($query_q_editpeserta, $connection) or die(mysql_error());
- $row_q_editpeserta = mysql_fetch_assoc($q_editpeserta);
- $totalRows_q_editpeserta = mysql_num_rows($q_editpeserta);
- }
- ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <title>Untitled Document</title>
- <style type="text/css">
- <!--
- .style1 {font-size: 18px}
- -->
- </style>
- </head>
- <body>
- <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
- <table align="center">
- <tr><th colspan="2">Kemaskini Data Peserta</th></tr>
- <tr valign="baseline">
- <td nowrap align="right">Idpeserta:</td>
- <td><?php echo $row_q_editpeserta['idpeserta']; ?></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Nama:</td>
- <td><input type="text" name="namapeserta" value="<?php echo $row_q_editpeserta['nama']; ?>" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">No KP:</td>
- <td><input type="text" name="nokp" value="<?php echo $row_q_editpeserta['nokp']; ?>" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Jantina:</td>
- <td><input type="text" name="jantina" value="<?php echo $row_q_editpeserta['jantina']; ?>" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Kelas:</td>
- <td><input type="text" name="namakelas" value="<?php echo $row_q_editpeserta['namakelas']; ?>" size="32"><input type="hidden"name="idkelas" value="<?php echo $row_q_editpeserta['kelas']; ?>" /></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right"> </td>
- <td><input type="submit" value="Update record"></td>
- </tr>
- </table>
- <input type="hidden" name="MM_update" value="form1">
- <input type="hidden" name="idpeserta" value="<?php echo $row_q_editpeserta['idpeserta']; ?>">
- </form>
- <p> </p>
- </body>
- </html>
- <?php
- mysql_free_result($q_editpeserta);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement