Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
data yang tampil "0"
jadi aku input data ke db. data berhasil tapi di tabel yang muncul malah nilai "0" dan di database pun terbaca "0"image.png
terus ini kodingan php utk input nya,
<?php
$host = "localhost";
$user = "root";
$pass = "";
$koneksi = "dbcashflow";
$koneksi = mysqli_connect($host, $user, $pass, $koneksi);
$reff = @$_data['reff'];
$saldoawal = @$_data['saldoawal'];
$kasmasuk = @$_data['kasmasuk'];
$kaskeluar = @$_data['kaskeluar'];
$saldoakhir = @$_data['saldoakhir'];
$simpan = mysqli_query ($koneksi, "INSERT into cashflow(saldoawal) VALUES ('$saldoawal')");
if($simpan) {
echo "Data berhasil disimpan";
} else {
echo "Data gagal disimpan";
}
?>
di bagian mananya yak yg error >w< mohon pencerahannya, terima kasih...
4 Jawaban:
<div>ini script dari form saldo,</div><pre><?php<br>$koneksi = mysqli_connect("localhost","root","","dbcashflow");<br><br>if (isset($_data["simpan"]) ){<br> $reff = $_data["reff"];<br> $saldoawal = $_data["saldoawal"];<br> $kasmasuk = $_data["kasmasuk"];<br> $kaskeluar = $_data["kaskeluar"];<br> $saldoakhir = $_data["saldoakhir"];<br> <br> $query = "INSERT INTO cashflow VALUES ('','$reff','$saldoawal','$kasmasuk','$kaskeluar','$saldoakhir') ";<br> mysqli_query($koneksi, $query);<br>}<br><br>?><br><html><br><head><br><title>Input Saldo Awal</title><br></head><br><body><br> <form action="savesaldoawal.php" method="post"><br> <table><br> <tr><td>Saldo Awal</td><td><input type="number_format name="saldoawal"</td></tr><br> <tr><td colspan="2"><button type="submit" name="simpan">SIMPAN</button></td></tr><br> </table><br></body></html> <br></pre><div><br>ini script form utk perintah simpannya<br><br></div><pre><?php $host = "localhost"; $user = "root"; $pass = ""; $koneksi = "dbcashflow";
$koneksi = mysqli_connect($host, $user, $pass, $koneksi);
$reff = @$_data['reff']; $saldoawal = @$_data['saldoawal']; $kasmasuk = @$_data['kasmasuk']; $kaskeluar = @$_data['kaskeluar']; $saldoakhir = @$_data['saldoakhir'];
$simpan = mysqli_query ($koneksi, "INSERT into cashflow(saldoawal) VALUES ('$saldoawal')"); if($simpan) { echo "Data berhasil disimpan"; } else { echo "Data gagal disimpan"; }
?> <html> <head> <title>Keterangan</title> </head> <body> <div><tr> <td><a href="index.php">Kembali Ke Halaman Utama</a></td> </div></tr> </body> </html> <br></pre><div><br>terus ini script dari index <br><br></div><pre><?php require 'koneksi.php'; $link = query("SELECT FROM dbcashflow"); ?> <html> <head> <title>Cash Flow</title> </head> <body> <form action ="" method = "post"> <table border="1"> <tr><th>Kode Reff</th> <th>Saldo Awal</th> <th>Kas Masuk</th> <th>Kas Keluar</th> <th>Opsi</th> <th>Saldo Akhir</th></tr>
&lt;tr&gt;
&lt;?php $reff=1; ?&gt;
&lt;?php $ambil = $koneksi-&gt;query("SELECT * FROM cashflow");?&gt;
&lt;?php while($data = $ambil-&gt;fetch_assoc()){?&gt;
&lt;tr&gt;
&lt;td&gt;&lt;?php echo $reff; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $data['saldoawal']?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $data['kasmasuk']?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $data['kaskeluar']?&gt;&lt;/td&gt;
&lt;td&gt;
&lt;a href =""&gt;Ubah&lt;/a&gt; |
&lt;a href ="hapus.php?reff=&lt;?= $data["reff"];?&gt;"&gt;Hapus&lt;/a&gt;
&lt;td&gt;&lt;?php echo $data['saldoawal']+$data['kasmasuk']-$data['kaskeluar'];?&gt;&lt;/td&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;?php $reff++;?&gt;
&lt;?php } ?&gt;
&lt;/tr&gt;
</table> <div><tr> <td><a href="saldoawal.php">Masukkan Saldo Awal</a></td> </div></tr> <div><tr> <td><a href="debit.php">Input Debit</a></td> </div></tr> <div><tr> <td><a href="kredit.php">Input Credit</a></td> </div></tr> </form> </body> </html> <br></pre><div><br></div>
<div>iyaa itu coba @$_data di ganti ke $_POST, bingung @$_data dari mana</div>