Jump to content

Php Help Me


Killua

Recommended Posts

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in ------- on line 30

 

<?php

include 'dbconfig.php';

echo "<center><big>Inputan Transaksi Jual</big></center>";

 

if(isset($_GET['action'] ) && ($_GET['action'] == 'delete')){

mysql_query("delete FROM sales where id_sales='".mysql_real_escape_string($_GET['id'])."'");

}

 

$idsales=$_POST['jual'];

$namasales=$_POST['sales'];

$idbar=$_POST['kd_barang'];

$namabar=$_POST['nama_barang'];

$jumlahjual=$_POST['jumlah_barang'];

$jumlahkembali=$_POST['jumlah_kembali'];

$tglambil=$_POST['tanggal_jual'];

 

 

$sql="insert into transaksijual values('".$_POST."','".$_POST['jual']."','".$_POST['sales']."','".$_POST['kd_barang']."','".$_POST['nama_barang']."','".$_POST['jumlah_barang']."','".$_POST['jumlah_kembali']."','".$_POST['tanggal_jual']."')";

 

if (! $result=mysql_query($sql, $dbh))

{

echo mysql_error();

return 0;

}

 

echo "<table border='1'>";

echo "<tr><td>ID Nomor Sales<td>Nama Sales<td>Kode Barang<td>Nama Barang<td>Jumlah Barang<td>Jumlah Kembali<td>Tanggal Jual</tr>";

 

$sql = "select max(id) as id_sales from sales limit 1";

$row = mysql_fetch_array(mysql_query($sql));

$id_sales = $row['id_sales'];

{

foreach($_POST['kd_barang'] as $key => $kode){

$sql = "insert into transaksijual(nomor_tjual,id_sales,nama_sales,kd_barang, nama_barang,jumlah_barang,jumlah_kembali,tanggal_jual)

values ('{$_POST}','{$_POST['jual']}','{$_POST['sales']}','{$idbar}','{$_POST['nama_barang'][$key]}','{$kode}','{$_POST['jumlah_barang'][$key]}','{$_POST['jumlah_kembali'][$key]}','{$_POST['tanggal_jual'][$key]}')";

mysql_query($sql);

}

echo 'Data telah disimpan';

echo "<tr>";

echo "<td>".$row[0];

echo "<td>".$row[1];

echo "<td>".$row[2];

echo "<td>".$row[3];

echo "<td>".$row[4];

echo "<td>".$row[5];

echo "<td>".$row[6];

echo "<td>";

echo '<a href="updaterincianjual.php?id='.$row['0'].'">Edit</a>';

echo ' | <a href="simpan-jual.php?id='.$row['0'].'&action=delete">Delete</a>';

echo "</td>";

echo "</tr>";

 

}

echo "</table>";

?>

<html>

<body>

<form action='welcome.php'>

<input type='submit' value='Home'>

</form>

</body>

</html>

 

<?php

mysql_close();

?>

Link to comment
https://forums.phpfreaks.com/topic/269927-php-help-me/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.