i want count point records from mysql db by id user using php to json endcode

15
March 14, 2019, at 8:20 PM

THIS IS MY DATABASE

this is my php for get record from mysql db help me to count point from database by user id i'm implement for my project using android studio can you help me how to count record using mysql query,,, thanks all...

<?php 
require_once"../konmysqli.php";
$respon = array();
if (isset($_GET["kode_pengguna"])) {
$kode_pengguna = $_GET['kode_pengguna'];
$sql="SELECT * FROM `$tbinvoice` WHERE `kode_pengguna` = 
'$kode_pengguna'";
$jum=getJum($conn,$sql);
if ($jum>0) {
$d=getField($conn,$sql);
$record = array();
$record["kode_pengguna"] = $d["kode_pengguna"];
$record["point"] = $d["point"];
$record["kode_invoice"] = $d["kode_invoice"];
$record["nomor_invoice"] = $d["nomor_invoice"];
$respon["sukses"] = 1;
$respon["record"] = array();
array_push($respon["record"], $record);
$respon["pesan"] = "$jum record";
echo json_encode($respon);
} else {
$respon["sukses"] = 0;
$respon["pesan"] = "0 record";
echo json_encode($respon);
}
} else {
$respon["sukses"] = 0;
$respon["pesan"] = "? lengkapi data";
echo json_encode($respon);
}
?>
<?php
function getJum($conn,$sql){
$rs=$conn->query($sql);
$jum= $rs->num_rows;
$rs->free();
return $jum;
}
function getField($conn,$sql){
$rs=$conn->query($sql);
$rs->data_seek(0);
$d= $rs->fetch_assoc();
$rs->free();
return $d;
}
?>
Answer 1

If you want to know the row quantity in a query you can use:

select count(*) from X_Table where X_Condition;
READ ALSO
Regular expression in bash or sed

Regular expression in bash or sed

I have a regular expression (PHP) to clean the string from file:

26
Wampserver php root relative path not working anymore

Wampserver php root relative path not working anymore

I am sorry for asking similiar question that have already been asked, but I did not find an answer to my problem

18
Merge Two Arrays to Have an Integer Value be an near equal as possible

Merge Two Arrays to Have an Integer Value be an near equal as possible

Application to Distribute Stock between Warehouses

22
I have 3 TLD .com .es .ru And I have a question

I have 3 TLD .com .es .ru And I have a question

I have a webpage translated into 3 languages, my question isI would like when you enter with

44