<?php require_once('koneksi/koneksi.php'); include('cek_login.php'); ?>
<!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=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include ('header.php') ?>
<div id="isi">
<div align="center"></div>
<center>
<h1>DATA JENIS PELATIHAN</h1> </center>
<a href="input_pelatihan.php">+Tambah Data</a>
<table border="1" cellpadding="3" cellspacing="0"><th>No</th><th>Kode</th><th>Nama</th><th>Nama Inggris</th><th>Jumlah Jam</th><th>Instruktur 1</th><th>Instruktur 2</th><th>Instruktur 3</th><th>Instruktur 4</th><th>Aksi</th>
<?php
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
$warna1= "FFFFFF";
$warna2= "#FFF8DC";
$warna= $warna1;
//jumlah data yg akan ditampilkan
$dataperpage=5;
if(isset($_GET['page']))
{
$nopage=$_GET['page'];
}
else $nopage=1;
// perhitungan offset
$offset=($nopage-1)*$dataperpage;
//query SQL untuk menampilkan data perhalaman sesuai offset
$query = "SELECT * FROM tpelatihan order by kd_plthn LIMIT $offset, $dataperpage";
$result= mysql_query($query) or die ('Error');
// membaca nomer halaman
// membuat nomer urut awal disetiap halaman berdasarkan formula diatas
$i=$nopage + ($nopage - 1) * ($dataperpage-1);
// menampilkan data
while($data=mysql_fetch_array($result))
{
//background berwarna
if($warna==$warna1){
$warna=$warna2;}
else {$warna=$warna1;}
$nomor++;
if($data['nip1']){
$nip1 = mysql_fetch_array(mysql_query("select * from tinstruktur where nip='".$data['nip1']."'"));
}
if($data['nip2']){
$nip2 = mysql_fetch_array(mysql_query("select * from tinstruktur where nip='".$data['nip2']."'"));
}
if($data['nip3']){
$nip3 = mysql_fetch_array(mysql_query("select * from tinstruktur where nip='".$data['nip3']."'"));
}
if($data['nip4']){
$nip4 = mysql_fetch_array(mysql_query("select * from tinstruktur where nip='".$data['nip4']."'"));
}
?>
<tr bgcolor=<?Php echo "$warna" ?> class='data'>
<td><?php echo "$i" ?></td><?php $i++; ?>
<td><?php echo "$data[kd_plthn]" ?></td>
<td><?php echo "$data[nm_plthn]" ?></td>
<td><?php echo "$data[nm_ing]" ?></td>
<td><?php echo "$data[jml_jam]" ?></td>
<td><?php echo !isset($nip1) ? '' : $nip1['nm_inst'];?></td>
<td><?php echo !isset($nip2) ? '' : $nip2['nm_inst'];?></td>
<td><?php echo !isset($nip3) ? '' : $nip3['nm_inst'];?></td>
<td><?php echo !isset($nip4) ? '' : $nip4['nm_inst'];?></td>
<td><table><tr><td><a href='edit_pelatihan.php?kd_plthn=<?php echo "$data[kd_plthn]"; ?>'>Ubah</a></td><td>|</td><td><a href='delete_pelatihan.php?kd_plthn=<?php echo "$data[kd_plthn]"; ?>' onclick="return confirm('Yakin akan hapus data <?php echo "$data[nm_plthn]"?>?')"> Hapus</a></td></tr></table></td>
</tr>
<?php
}
?>
</table>
<p><center>
<?php
// mencari jumlah semua data dalam tabel siswa
$query = "SELECT COUNT(*) AS jumdata FROM tpelatihan";
$hasil = mysql_query($query);
$data = mysql_fetch_array($hasil);
$jumdata=$data['jumdata'];
// menentukan jumlah halaman yang muncul berdasarkan jumlah semua data
$jumpage = ceil($jumdata/$dataperpage);
// menampilkan link previous
if ($nopage > 1) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($nopage-1)."'><< sebelumnya</a>";
// memunculkan nomor halaman dan linknya
for($page = 1; $page <= $jumpage; $page++)
{
if ((($page >= $nopage - 3) && ($page <= $nopage + 3)) || ($page == 1) || ($page == $jumpage))
{
if (($showpage == 1) && ($page != 2)) echo "...";
if (($showpage != ($jumpage - 1)) && ($page == $jumpage)) echo "...";
if ($page == $nopage) echo " <b>".$page."</b> ";
else echo " <a href='".$_SERVER['PHP_SELF']."?page=".$page."'>".$page."</a> ";
$showpage = $page;
}
}
// menampilkan link next
if ($nopage < $jumpage) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($nopage+1)."'>Selanjutnya>></a>";
?>
</p>
<p> </p>
</div>
<?php include ('footer.php') ?>
</body>
</html>
yang saya tanyakan lagi, bagaimana cara membuat halaman edit jenis pelatihan dengan nama instruktur yang telah dimasukkan akan muncul sesuai dengan data yang telah ada, saya telah membuat halaman edit seperti ini, tetapi nama instrukturnya tidak dapat muncul sesuai dengan yang telah dimasukkan sebelumnya,mohon bantuannya lagi mas, terimakasih<?php require_once('koneksi/koneksi.php'); ?>
<!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=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include ('header.php') ?>
<div id="isi">
<div align="center"></div>
<center>
<h1>UBAH DATA PELATIHAN</h1>
<?php
$kd_plthn=$_GET['kd_plthn'];
$query=mysql_query("SELECT * FROM tpelatihan where kd_plthn='$kd_plthn'") or die(mysql_error());
$data=mysql_fetch_array($query);
?>
<form name="edit" method="POST" action="aksi_edit_pelatihan.php">
<input type="hidden" name="kd_plthn" value="<?php echo $data['kd_plthn']; ?>" />
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td>Kode Pelatihan</td>
<td>:</td>
<td>
<input type="text" name="kd_plthn" maxlength="4" size="4" value="<?php echo $data['kd_plthn']; ?>" />
</td>
</tr>
<tr>
<td>Nama Pelatihan</td>
<td>:</td>
<td>
<input type="text" name="nm_plthn" maxlength="30" size="30" value="<?php echo $data['nm_plthn']; ?>" />
</td>
</tr>
<tr>
<td>Nama Inggris</td>
<td>:</td>
<td><input type="text" name="nm_ing" maxlength="30" size="35" value="<?php echo $data['nm_ing']; ?>" /></td>
</tr>
<tr>
<td>Jumlah Jam</td>
<td>:</td>
<td>
<input name="jml_jam" type="radio" value="120" <?php if ($data['jml_jam']=='120') echo "checked" ?> />120
<input name="jml_jam" type="radio" value="240" <?php if ($data['jml_jam']=='240') echo "checked" ?> />240
</td>
</tr>
<tr>
<td>Instruktur 1</td>
<td>:</td>
<td>
<select name="nip1" >
<?php
$sql="SELECT * FROM tinstruktur";
$hasil=mysql_query($sql);
while($baris=mysql_fetch_object($hasil))
{
echo'<option value="'.$baris->nm_inst.'"'.($baris->nm_inst==$data['nip1']?'selected="selected"' : '').'>'.$baris->nm_inst.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>Instruktur 2</td>
<td>:</td>
<td>
<select name="nip2" >
<?php
$sql="SELECT * FROM tinstruktur";
$hasil=mysql_query($sql);
while($baris=mysql_fetch_object($hasil))
{
echo'<option value="'.$baris->nm_inst.'"'.($baris->nm_inst==$data['nip2']?'selected="selected"' : '').'>'.$baris->nm_inst.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>Instruktur 3</td>
<td>:</td>
<td>
<select name="nip3" >
<option value="-"></option>
<?php
$sql="SELECT * FROM tinstruktur";
$hasil=mysql_query($sql);
while($baris=mysql_fetch_object($hasil))
{
echo'<option value="'.$baris->nm_inst.'"'.($baris->nm_inst==$data['nip3']?'selected="selected"' : '').'>'.$baris->nm_inst.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td>Instruktur 4</td>
<td>:</td>
<td>
<select name="nip4" >
<option value="-"></option>
<?php
$sql="SELECT * FROM tinstruktur";
$hasil=mysql_query($sql);
while($baris=mysql_fetch_object($hasil))
{
echo'<option value="'.$baris->nm_inst.'"'.($baris->nm_inst==$data['nip4']?'selected="selected"' : '').'>'.$baris->nm_inst.'</option>';
}
?>
</select>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<input type="submit" value="Simpan" name="submit"/> <input type="reset" value="Batal" name="reset"/> <input type="button" value="Kembali" onClick="history.go(-1);">
</td>
</tr>
</table>
</form>
</center></div>
<?php include ('footer.php') ?>
</body>
</html>
oya mas, relasi anatar tabel pelatihan dan instruktur nya adalah satu kebanyak, jadi tiap jenis pelatihan minimal 2 instruktur atau maksimal 4,jadi tiap instruktur hanya mengajar satu pelatihan saja. <html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>JPEGCam Test Page</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Joseph Huckaby">
<!-- Date: 2008-03-15 -->
<!-- First, include the JPEGCam JavaScript Library -->
<script type="text/javascript" src="webcam.js"></script>
<!-- Configure a few settings -->
<script language="JavaScript">
webcam.set_api_url( 'test.php' );
webcam.set_quality( 90 ); // JPEG quality (1 - 100)
webcam.set_shutter_sound( true ); // play shutter click sound
</script>
<!-- Next, write the movie to the page at 320x240 -->
<script language="JavaScript">
document.write( webcam.get_html(320, 240) );
</script>
</head>
<body>
<table><tr><td valign=top>
<h1>JPEGCam Test Page</h1>
<h3>Demonstrates a very simple, one-click capture & upload implementation</h3>
<!-- Some buttons for controlling things -->
<br/><form>
<input type=button value="Configure..." onClick="webcam.configure()">
<input type=button value="Take Snapshot" onClick="take_snapshot()">
</form>
<!-- Code to handle the server response (see test.php) -->
<script language="JavaScript">
webcam.set_hook( 'onComplete', 'my_completion_handler' );
function take_snapshot() {
// take snapshot and upload to server
document.getElementById('upload_results').innerHTML = '<h1>Uploading...</h1>';
webcam.snap();
}
function my_completion_handler(msg) {
// extract URL out of PHP output
if (msg.match(/(http\:\/\/\S+)/)) {
var image_url = RegExp.$1;
// show JPEG image in page
document.getElementById('upload_results').innerHTML =
'<h1>Upload Successful!</h1>' +
'<h3>JPEG URL: ' + image_url + '</h3>' +
'<img src="' + image_url + '">';
// reset camera for another shot
webcam.reset();
}
else alert("PHP Error: " + msg);
}
</script>
</td><td width=50> </td><td valign=top>
<div id="upload_results" style="background-color:#eee;"></div>
</td></tr></table>
</body>
</html>
$lastLine = system('D:\\Cpp\\new\\Untitled10A.exe');
echo "<br/>LastLine: $lastLine<br/>";
output nya berhasil saya tampilkan di halaman PHP,,
<h4> Manajemen Mata Kuliah Mahasiswa/ I</h4>
<form method=post action=index.php?menu=tambah_nilai1>
<table>
<tr>
<td> Masukkan NIS </td>
<td> : </td>
<td> <input type=text name=makul maxlength=10> </td>
</tr>
<tr>
<td colspan=3> <input type=submit value=GO> </td>
</tr>
</table>
</form>
berikut coding selanjutnya<h1>Update Nilai</h1>
<form method=post action=?menu=create_nilai>
<table border="1">
<tr><td>No</td><td>NIM</td><td>Nilai</td></tr>
<?php
include "koneksi/koneksi.php";
// membaca kode matakuliah yang disubmit dari formnilai.php
$makul = $_POST['makul'];
// menampilkan data nim dan nilai mahasiswa yang mengambil matakuliah berdasarkan kode MK
$query = "SELECT nis, nilai FROM kontra WHERE makul = '$makul'";
$hasil = mysql_query($query);
// inisialisasi counter
$i = 1;
while ($data = mysql_fetch_array($hasil))
{
echo "<tr><td>".$i."</td><td>".$data['nis']."</td><td><input type='hidden' name='mhs".$i."' value='".$data['nis']."' />
<input type='text' name='nilai".$i."' value='".$data['nilai']."' /></td></tr>";
$i++;
}
$jumMhs = $i-1;
?>
</table><br />
<input type="hidden" name="n" value="<?php echo $jumMhs ?>" />
<input type="hidden" name="makul" value="<?php echo $makul;?>">
<input type="submit" value="Update" name="submit" />
</form>
dan coding terakhir<?php
include "koneksi/koneksi.php";
// membaca jumlah mahasiswa (n) dari submit.php
$jumMhs = $_POST['n'];
// membaca kode MK yang akan diupdate
$makul = $_POST['makul'];
// proses looping untuk membaca nilai dan nim mahasiswa dari form, serta menjalankan query update
for ($i=1; $i<=$n; $i++)
{
// membaca nim mahasiswa ke-i, i = 1, 2, 3, ..., n
$nimMhs = $_POST['mhs'.$i];
// membaca nilai mahasiswa ke-i, i = 1, 2, 3, ..., n
$nilai = $_POST['nilai'.$i];
// update nilai mahasiswa ke-i, i = 1, 2, 3, ..., n
$q = mysql_query("update kontra set nilai= $nilai where makul='$makul'");
//$query = "UPDATE kontra SET nilai = $nilai WHERE makul = '$makul'";
mysql_query($query);
}
if ($q){
echo"Data Berhasil disimpan";
}
else
{
echo $makul;
echo $nimMhs;
echo"Data Gagal Disimpan";
}
?>