Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.