Selamat sore agan2, mohon pencerahannya.
Saya membuat membuat perhitungan rata2 pada tabel array, pada row pertama berhasil menghitung namun pada row berikutnya gagal. mohon bantuannya, terima kasih agan2...

https://img1.uploadhouse.com/fileuploads/26092/260925516e556090107abe660965bdcf9160283e.jpg

<script language="javascript" >
function OperasiPerhitungan(){
A1 = document.getElementById("angka1").value;
A2 = document.getElementById("angka2").value;
A3 = (parseFloat(A1) + parseFloat(A2))/2;
document.getElementById("hasil").value =A3;
}
</script>
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
		<div class="row">
			<div class="col-lg-12">
				<center><h3 class="page-header">EDIT NILAI</h3></center>
			</div>
		</div><!--/.row-->	
        <?php include ('koneksi.php');
        $nip=$_SESSION['$nip'];
        ?>
<div class="row">
			<div class="col-lg-12">
				<div class="panel panel-danger">
					<div class="panel-body">
					<form method="POST" action="input_nilai_edit_proses.php">
						<table id="example" class="" cellspacing="0" width="100%">
						        <thead>
						            <tr class="alert warning">
						            	<th>No</th>
						            	<th></th>
						            	<th>NIS</th>
						            	<th>Siswa</th>
						            	<th>UH 1</th>
						            	<th>UH 2</th>
								<th>RERATA</th>
						            </tr>
						        </thead>						
						        <tbody>
								<?php
								include('koneksi.php');
								$id_mapel = $_GET['id_mapel'];
								$query = mysql_query("SELECT siswa.nama,nilai.id_mapel, nilai.id_nilai, 
								nilai.nis, nilai.uh1,nilai.uh2
								FROM siswa, nilai WHERE siswa.nis=nilai.nis AND nilai.id_mapel= '$id_mapel'");
								 $no = 0;	//membuat variabel $no untuk membuat nomor urut
								while($data = mysql_fetch_array($query)){
								 $no++;
								 $id_nilai = $data['id_nilai'];
								$id_mapel = $data['id_mapel'];
								$rerata = $data['rerata'];
								?>
				<tr>
				<td><?php echo $no; ?></td>
				<td><input type="hidden" name="id_nilai[]" value="<?php echo $data['id_nilai']; ?>"></td>
				<td><?php echo $data['nis']; ?></td>
				<td><?php echo $data['nama']; ?></td>
				<td><input type="number" name="uh1[]" id="angka1" onchange="OperasiPerhitungan();" value="0" style="width:50px"></td>
				<td><input type="number" name="uh2[]" id="angka2" onchange="OperasiPerhitungan();" value="0" style="width:50px"></td>
				<td><input type="number" name="rerata[]" id="hasil" disabled="disabled" value="0" style="width:80px"></td>
				</tr>
						            <?php } ?>
						    	</tbody>
						    </table>
							<div class='navbar-form pull-left'>
							<button type="submit" name="tambah" class="btn btn-danger">Simpan</button>
							</div>
						</form> 
Silahkan login untuk menjawab!
Mohon bantuannya para master sekalian..
Saya membuat script yg mengruangi tanggal, contohnya jika tanggal sekarang - tanggal mulai hasilnya sama dengan atau kurang dari 3 hari maka waktunya on time, jika lebih besar dari 3 maka waktunya over time.

pertanyaannya
pas hasilnya kurang dari atau sama dengan 3 waktunya over time, pokoknya jika hasilnya positif waktunya pasti over time. giliran hasilnya negatif baru waktunya on time.
ini script yg saya buat
$tanggal  = strtotime('2018-05-22');
$sekarang    = time(); // Waktu sekarang
$diff   = $sekarang - $tanggal ;
echo 'Waktu pengerjaan yaitu ' . floor($diff / (60 * 60 * 24)).' Hari'.'<br><br>';
if ($diff <= 3){
	echo ' Ontime';
}else{
	echo ' Over time';
mohon bantuannya jika ada kesalahan.
Terima kasih
Silahkan login untuk menjawab!
Mohon bantuannya para master sekalian..
Saya ingin membuat script dimana jika kita memilih salah satu value pada combobox maka pada combobox yang lainnya menampilkan data dari database.
contohnya dalam combobox1 terdapat 3 value yaitu 1,2,3. ketika kita memilih 1 maka kita akan menampilkan data pada combobox2 dari tabel 1.
mohon bantuannya.
Terima kasih
Silahkan login untuk menjawab!
saya mau menampilkan data dari tabel jasa, berdasrkan combobox yang ada..saya make method post..disini ada 5 combobox, sebelum dipilih combobox yg awa, combobox selanjutnya nonaktif.. nah jd klo saya cuma pilih beberapa combobox untuk menampilkan data, dia muncul error karena combobox yg nonaktif itu saya panggil method post nya...harusnya seprti apa ya codingannya ??
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
  <!-- BASICS -->
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Price List</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" type="text/css" href="css/isotope.css" media="screen" />
  <link rel="stylesheet" href="js/fancybox/jquery.fancybox.css" type="text/css" media="screen" />
  <link rel="stylesheet" href="css/bootstrap.css">
  <link rel="stylesheet" href="css/bootstrap-theme.css">
  <link rel="stylesheet" href="css/style.css">
  <!-- skin -->
  <link rel="stylesheet" href="skin/default.css">
  <!-- =======================================================
    Theme Name: Amoeba
    Theme URL: https://bootstrapmade.com/free-one-page-bootstrap-template-amoeba/
    Author: BootstrapMade
    Author URL: https://bootstrapmade.com
	 class="navbar-brand"
  ======================================================= -->
</head>

<body>
  <section id="header" class="appear"></section>
  <div class="navbar navbar-fixed-top" role="navigation" data-0="line-height:100px; height:100px; background-color:rgba(0,0,0,0.3);" data-300="line-height:60px; height:60px; background-color:rgba(0,0,0,1);">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
						<span class="fa fa-bars color-white"></span>
					</button>
        <h1><a href="pricelist.php" data-0="line-height:90px;" data-300="line-height:50px;"><i class="fa fa-flask fa-2x mar-bot20"></i>  TABELKU
					</a></h1>
      </div>
      <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav" data-0="margin-top:20px;" data-300="margin-top:5px;"> 
          <!--<li class="active"><a href="index.html">Home</a></li>
          <li><a href="#section-about">About</a></li>
          <li><a href="#section-works">Portfolio</a></li>
          <li><a href="#section-contact">Contact</a></li>-->
        </ul>
      </div>
      <!--/.navbar-collapse -->
    </div>
  </div>

  <section class="featured" color="#000000">
    <div class="container" color="#000000">
      <div class="row mar-bot40">
        <div class="col-md-100 col-md-offset-0">

          <div class="align-center" margin-left="10px" >
            <!--<i class="fa fa-flask fa-5x mar-bot20"></i>
            <h2 class="slogan">TABELKU</h2>-->
            <p>
              
			  
			  <html>
<?php
//        koneksi ke database
        //mysql_connect('localhost', 'username', 'password');
        //mysql_select_db('belajar');
		include "config.php";
        ?>
        <form method="post">
            
            <!--sbu-->
			SBU :
            <select class='Menu' style="width:200px" id="sbu" name="sbu">
                <option value=''>Please Select</option>
                <?php
                $query = mysqli_query($db, "SELECT * FROM sbu ORDER BY nm_sbu");
                while ($row = mysqli_fetch_array($query)) {
                ?>
                    <option value="<?php echo $row['kd_sbu']; ?>">
                        <?php echo $row['nm_sbu']; ?>
                    </option>
                <?php
                }
                ?>
            </select>
            
            <!--bid-->
			BIDANG :
            <select class='Menu' style="width:200px" id="bid" name="bid">
                <option value=''>Please Select</option>
                <?php
                $query = mysqli_query($db, "SELECT * FROM bid
                                    INNER JOIN sbu ON bid.kd_sbu = sbu.kd_sbu where bid.operasional = 1 ORDER BY nm_bid");
                while ($row = mysqli_fetch_array($query)) {
                ?>
                    <option id="kota" class="<?php echo $row['kd_sbu']; ?>" value="<?php echo $row['kd_bid']; ?>">
                        <?php echo $row['nm_bid']; ?>
                    </option>
                <?php
                }
                ?>
            </select>
 
            <!--subbid-->
			SUB BIDANG :
            <select class='Menu' style="width:200px" id="subbid" name="subbid">
                <option value=''>Please Select</option>
                <?php
                $query = mysqli_query($db, "SELECT * FROM subbid
                                        INNER JOIN bid ON subbid.kd_bid = bid.kd_bid ORDER BY nm_subbid");
                while ($row = mysqli_fetch_array($query)) {
                ?>
                    <option id="subbid" class="<?php echo $row['kd_bid']; ?>" value="<?php echo $row['kd_subbid']; ?>">
                        <?php echo $row['nm_subbid']; ?>
                    </option>
                <?php
                }
                ?>
            </select>
 
            <!--gkom-->
			GRUP KOMODITI :
            <select class='Menu' style="width:200px" id="gkom" name="gkom">
                <option value=''>Please Select</option>
                <?php
                $query = mysqli_query($db, "SELECT * FROM gkom
                                        INNER JOIN subbid ON gkom.kd_subbid = subbid.kd_subbid ORDER BY nm_gkom");
                while ($row = mysqli_fetch_array($query)) {
                ?>
                    <option id="gkom" class="<?php echo $row['kd_subbid']; ?>" value="<?php echo $row['kd_gkom']; ?>">
                        <?php echo $row['nm_gkom']; ?>
                    </option>
                <?php
                }
                ?>
            </select>
 
            <!--kom-->
			KOMODITI :
            <select class='Menu' style="width:200px" id="kom" name="kom">
                <option value=''>Please Select</option>
                <?php
                $query = mysqli_query($db, "SELECT * FROM komoditi
                                        INNER JOIN gkom ON komoditi.kd_gkom = gkom.kd_gkom ORDER BY nm_komoditi_ind");
                while ($row = mysqli_fetch_array($query)) {
                ?>
                    <option id="kom" class="<?php echo $row['kd_gkom']; ?>" value="<?php echo $row['kd_komoditi']; ?>">
                        <?php echo $row['nm_komoditi_ind']; ?>
                    </option>
                <?php
                }
                ?>
            </select>
        
<td>SEARCH :</td>
<td><input class='search' type="text" name="txtsearch" style="width:200px" value="" /> </td>
<td><input class='cari' type="submit" value="Cari" name="submit" style="width:70px"/></td>
<br></br>

</form>

        <script src="jquery-1.10.2.min.js"></script>
        <script src="jquery.chained.min.js"></script>
        <script>
            $("#bid").chained("#sbu");
            $("#subbid").chained("#bid");
            $("#gkom").chained("#subbid");
            $("#kom").chained("#gkom");
            //$("#subbid").chained("#kom");
        </script>


<!-- tabel -->


<?php  
  if (isset($_POST['submit'])) {
   $search = $_POST['txtsearch'];  
   $sbunya = $_POST['sbu'];  
   $bidnya = $_POST['bid']; 
   $subbidnya = $_POST['subbid']; 
   $gkomnya = $_POST['gkom']; 
   $komnya = $_POST['kom'];
   
   
   if ($bidnya == ''){
	   if ($search == ''){
		  $sql = "SELECT * FROM jasa WHERE kd_sbu = '$sbunya'"; 
	   } else {
		  $sql = "SELECT * FROM jasa WHERE kd_sbu = '$sbunya' and nm_jasa_ind like '%$search%'";
	   }	   
   } else if ($subbidnya == ''){
	   if ($search == ''){
		   $sql = "SELECT * FROM jasa WHERE kd_sbu = '$sbunya' and kd_bid = '$bidnya'";
	   } else {
		   $sql = "SELECT * FROM jasa WHERE kd_sbu = '$sbunya' and kd_bid = '$bidnya' and nm_jasa_ind like '%$search%'";
	   }
   } else if ($gkomnya == ''){
	   if ($search == ''){
	   $sql = "SELECT * FROM jasa WHERE kd_sbu = '$sbunya' and kd_bid = '$bidnya' and kd_subbid = '$subbidnya'";
	   } else {
	   $sql = "SELECT * FROM jasa WHERE kd_sbu = '$sbunya' and kd_bid = '$bidnya' and kd_subbid = '$subbidnya' and nm_jasa_ind like '%$search%'";
	   }
   } else if ($komnya == ''){
	   if ($search == ''){
	   $sql = "SELECT * FROM jasa WHERE kd_sbu = '$sbunya' and kd_bid = '$bidnya' and kd_subbid = '$subbidnya' and kd_gkom = '$gkomnya'";
	   } else {
	   $sql = "SELECT * FROM jasa WHERE kd_sbu = '$sbunya' and kd_bid = '$bidnya' and kd_subbid = '$subbidnya' and kd_gkom = '$gkomnya' and nm_jasa_ind like '%$search%'";
	   }
   } else {
	   if ($search == ''){
	   $sql = "SELECT * FROM jasa WHERE kd_sbu = '$sbunya' and kd_bid = '$bidnya' and kd_subbid = '$subbidnya' and kd_gkom = '$gkomnya' and kd_komoditi = '$komnya'";
	   } else {
	   $sql = "SELECT * FROM jasa WHERE kd_sbu = '$sbunya' and kd_bid = '$bidnya' and kd_subbid = '$subbidnya' and kd_gkom = '$gkomnya' and kd_komoditi = '$komnya' and nm_jasa_ind like '%$search%'";
	   }
   }
   
   $i=1;
   $result = mysqli_query($db, $sql) or die('Error, list jasa failed. ' . mysqli_error());  
       
   if (mysqli_num_rows($result) == 0) { 
    echo '<p></p><p>Pencarian tidak ditemukan</p>';  
   } else {  
    //echo '<p></p>';
	
	echo '<table style="table-layout: fixed" border="2" width="1200px">';	 
     echo '<tr><td width="50px">No.</td>'; 
     echo '<td width="600px">Nama Jasa</td>'; 
     echo '<td width="150px">Methode</td>'; 
     echo '<td width="150px">Persyaratan</td>'; 
     echo '<td width="70px">Sat Harga</td>'; 
     echo '<td width="100px">Harga</td></tr>';
	 
    while ($row = mysqli_fetch_array($result)) {  
     extract($row); 
	$harga = $row['hrg'];
	$hargaa = number_format($harga,0,',','.');
	 
     echo '<tr><td align="top">'.$i.'</td>'; 
     echo '<td align="left">'.$nm_jasa_ind.'</td>';  
     echo '<td align="top">'.$methode.'</td>'; 
     echo '<td align="top">'.$persyaratan.'</td>'; 
     echo '<td align="top">'.$sat_hrg.'</td>'; 
     echo '<td align="right">'.$hargaa.'</td></tr>';  
     $i++;
    }
     echo '</table>';
     echo '<p></p>';
   }
  }
?>  
<!--</form>-->
			  
			  
            </p>
          </div>
        </div>
      </div>
    </div>
  </section>
  </body>

</html>
Silahkan login untuk menjawab!

combobox pada php

annisa · Apr 9, 2018
haloo..saya buat combobox bercabang di php dari mysql, kayanya data dari field yg saya akan tampilkan ke combobox itu kepanjangan deh, jd dia gamau tampil..gimana cara nya supaya bisa tampil yah ? kalau harus dipotong karakternya ntar jd ga kebaca semua donng..mohon bantuannya.. terima kasih. *saya lampirkan kodingan saya..
<script language='javascript'>

function showKom()

{

<?php

include"config.php";

// membaca semua propinsi

$query = "SELECT * FROM gkom";

$hasil = mysqli_query($db, $query);

// membuat if untuk masing-masing pilihan propinsi beserta isi option untuk combobox kedua

while ($data = mysqli_fetch_array($hasil))

{

$gkom = $data['kd_gkom'];
// membuat IF untuk masing-masing propinsi

echo "if (document.form1.gkom.value == \"".$gkom."\")";

echo "{";

// membuat option kota untuk masing-masing propinsi

$query2 = "SELECT * FROM komoditi WHERE kd_gkom = '$gkom'";

$hasil2 = mysqli_query($db, $query2);

$content = "document.getElementById('kom').innerHTML = \"";

while ($data2 = mysqli_fetch_array($hasil2))

	//$nm_kom = substr($data2['nm_komoditi_ind'],0);
{
$content .= "<option value='".$data2['kd_komoditi']."'>".$data2['nm_komoditi_ind']."</option>";
}

$content .= "\"";

echo $content;

echo "}\n";

}

?>

}

</script>
Silahkan login untuk menjawab!
<?php
include "../../config/koneksi.php";

$barcode	=$_POST['barcode'];
$tglscn		=$_POST['tgl'];
$user		=$_POST['user'];	
$kndsi		=$_POST['kndsi'];
$tgl = substr($barcode,4,6);
$tgl = date('d-m-Y', strtotime($tgl));


$query = mysql_query("INSERT INTO scan_nrb (barcode,tgl_scan,user,kondisi) VALUES ('$barcode','$tglscn','$user','$kndsi')");
if ($query)
{

	$query2 = mysql_query("UPDATE scan_nrb SET toko=LEFT(barcode,4),tgl='$tgl',NO=RIGHT(barcode,4) where barcode='$barcode';") or die(mysql_error());
		 echo "<META HTTP-EQUIV=Refresh CONTENT='0; URL=../../media.php?module=reg-nrb'>";
}	
else
{ 
	echo "gagal ..."; 
}
?>
master mau tanya dong, gimana ya caranya supaya data tgl yg ada di db menjadi tanggal indo.

contoh barcode nya TEST2811171234 yg 281117 itu adalah tanggal.
kode yg saya buat seperti di atas, terimakasih:)
Silahkan login untuk menjawab!