vendredi 24 juin 2016

get value mysql count and save to table

What i have here is to get the value of my count and save to my table but it's not working. I just want to get the count value, can you help me ? i will appreciate any answer. No problem with displaying with count but only in saving in my table. <form method="POST"> Date : <input type="text" value="<?=$p_date?>" name="datereceived" /> <input type="submit" name="save" value="save"> </form> **PHP** <? $sql="SELECT allinvty3.*, barcode.* , sample.*, count(barcode.itemcode) as icount from barcode INNER JOIN sample on barcode.itemcode = sample.in_code INNER JOIN allinvty3 on barcode.itemcode = allinvty3.in_code where barcode.refnumber='$temp' group by barcode.itemcode"; $result = $conn->query($sql); while($row = $result->fetch_assoc()) { $icount = $row['icount']; } if(isset($_POST['save'])){ $sql = "UPDATE barcode SET datereceived ='$p_date' , actualacount ='".$icount."' , status='COMPLETE' WHERE status='PENDING'"; $conn->query($sql) ; } ?>

Aucun commentaire:

Enregistrer un commentaire