![]() |
| Insert Multiple Record |
Cekidot ..
<?php
//variabel dan kode awal untuk menentukan posisi halaman saat ini
//dipakai untuk melimit quiery
$BatasAwal = 500;
if (!empty($_GET['record'])) {
$hal = $_GET['record'] - 1;
$MulaiAwal = $BatasAwal * $hal;
} else if (!empty($_GET['record']) and $_GET['record'] == 1) {
$MulaiAwal = 0;
} else if (empty($_GET['record'])) {
$MulaiAwal = 0;
} ?>
<form action="" method="post">
<div class="grid_6" >
<table cellpadding="0" cellspacing="0" id="tabel" >
<tr class="table">
<th width="38"><center>No.</center></th>
<th width="50">Nis</th>
<th width="124">Nama</th>
<th width="124">Nilai_1</th>
<th width="124">Nilai_2</th>
<th colspan="2" ><center>Actions</center></th>
</tr >
<?php //tampil
$warnaGanjil = "#E8E9EE"; // warna Abu Abu
$warnaGenap = "#E7FEF4"; // warna Hijau
$query =mysql_query("SELECT * FROM siswa ");
//$siswa=mysql_query($query) or die (mysql_error());
while($row=mysql_fetch_array($query))
{
//Jumlah Hasil Pencarian
$jumlah = mysql_num_rows($query);
if ($no % 2 == 0) $warna = $warnaGenap;
else $warna = $warnaGanjil;
$no++;
echo "<tr bgcolor='".$warna."' >"
?>
<tr>
<td><center><?php echo $no?></center></td>
<td><input name="nis[]" type="text" value="<?php echo $row[nis];?>" /></td>
<td><a href="akademik/main.php?page=profil&nis=<?php echo $row[nis];?>">
<?php echo $row [nama_siswa];?>
</a></td>
<td><input class="nilai" type="text" maxlength="2" name="nilai1[]"/></td>
<td><input class="nilai" type="text" maxlength="2" name="nilai2[]"/></td>
<td width="43"><a href="akademik/main.php?page=updatesiswa&nis=<?php echo $row[nis];?>"> Update </a> </td>
<td width="47"> <a href="akademik/delete_siswa.php?id=<?php echo $row[nis];?>" onclick="return confirm('Yakin Hapus Data Siswa Dengan NIS <?php echo $row[nis];?> Dengan Nama <?php echo $row[nama_siswa];?>')" >Hapus</a></td>
</tr>
<?php
}
?>
</table>
<br>
<div class="pagination">
<div class="curved">
<?php
//navigasi
$cekQuery = mysql_query("SELECT * FROM siswa");
$jumlahData = mysql_num_rows($cekQuery);
//jumlahketemu
if ($jumlah > 0){
echo '<center>['.$jumlah.'] Record Found.</center>';
'<hr/>';
}
else
{
echo '<center>Tidak Ditemukan Data.</center>';
}
if ($jumlahData > $BatasAwal) {
echo '<center><div style="font-size:13px; font-family:Arial;">Record : ';
$a = explode(".", $jumlahData / $BatasAwal);
$b = $a[0];
$c = $b + 1;
for ($i = 1; $i <= $c; $i++) {
echo '<a style="text-decoration:none;';
if ($_GET['record'] == $i) {
echo 'font-weight:bold;color:red;text-decoration:block;';
}
echo '" href="?page=daftarsiswa&record='. $i . '">' . $i .'</a>||';
}
echo '</center>';
}
?>
</div>
<div><input type="submit" name="submit" class="submit" /></div>
<div>_______________________________________________</div>
</div>
</div></form>
<?php
if(isset($_POST['submit'])){
$nilai1 = $_POST['nilai1'];
$nilai2 = $_POST['nilai2'];
$nis = $_POST['nis'];
for($i = 0; $i < $jumlahData; $i++){
$query = "INSERT INTO nilai_praktik (id_nilai_praktik, nis,nilai_prak1, nilai_prak2) VALUES ('', '$nis[$i]', '$nilai1[$i]', '$nilai2[$i]')";
// $query_nilaiupdate = "UPDATE nilai set nilai = '".$nilai[$i]."' where
// nim = '".$nim[$i]."' && kodemk = '".$kodemk[$i]."'";
mysql_query($query) or die (mysql_error());
}
echo "Data telah diupdate <a href=nilai_view.php>Refresh</a>";
mysql_close();
}
?>
salam Semrawood
About sedikitnoise
Hi, My Name is Hafeez. I am a webdesigner, blogspot developer and UI designer. I am a certified Themeforest top contributor and popular at JavaScript engineers. We have a team of professinal programmers, developers work together and make unique blogger templates.


2 comments:
http://dewikhawa.blogspot.com/
SIPP, siap Dimasukkan ...
Posting Komentar