$query = "SELECT * FROM tpelatihan,tinstruktur WHERE tinstruktur.nip=tpelatihan.nip1 or tinstruktur.nip=tpelatihan.nip2 or tinstruktur.nip=tpelatihan.nip3 or tinstruktur.nip=tpelatihan.nip4 order by kd_plthn LIMIT $offset, $dataperpage";
$result= mysql_query($query) or die ('Error');
$query = "SELECT * FROM tpelatihan order by kd_plthn LIMIT $offset, $dataperpage";
$result= mysql_query($query);
while($data = mysql_fetch_array($result)){
if($data['nip1']){
$nip1 = mysql_fetch_array(mysql_query("select * from tinstruktur where nip='".$data['nip1']."'"));
echo 'Instruktur1:'.$nip1['nama_instruktur'];
}
if($data['nip2']){
$nip2 = mysql_fetch_array(mysql_query("select * from tinstruktur where nip='".$data['nip2']."'"));
echo 'Instruktur2:'.$nip2['nama_instruktur'];
}
if($data['nip3']){
$nip3 = mysql_fetch_array(mysql_query("select * from tinstruktur where nip='".$data['nip3']."'"));
echo 'Instruktur3:'.$nip3['nama_instruktur'];
}
if($data['nip4']){
$nip4 = mysql_fetch_array(mysql_query("select * from tinstruktur where nip='".$data['nip4']."'"));
echo 'Instruktur4:'.$nip4['nama_instruktur'];
}
}
<?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,tinstruktur WHERE tinstruktur.nip=tpelatihan.nip1 or tinstruktur.nip=tpelatihan.nip2 or tinstruktur.nip=tpelatihan.nip3 or tinstruktur.nip=tpelatihan.nip4 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++;
?>
<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 "$data[nm_inst]" ?></td>
<td><?php echo "$data[nm_inst]" ?></td>
<td><?php echo "$data[nm_inst]" ?></td>
<td><?php echo "$data[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>
<?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>
<?php require_once('koneksi/koneksi.php'); ?>
<?php
function kosong()
{
$myquery="select * from tinstruktur";
$sql_result=mysql_query($myquery) or die (mysql_error());
if(mysql_num_rows($sql_result))
{
while($row = mysql_fetch_assoc($sql_result))
{ echo "<option>$row[nm_inst]</option>"; }
}
else {echo "<option>No Names Present</option>";}
}
?>
<!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>
masih belum jadi, mohon bantuannya.btw,untuk relasinya dari instruktur ke pelatihan adalah satu kebanyak bukan banyak ke banyak.jadi instruktur yang mengampu suatu pelatihan paling sedikit 2 orang.