Note that there are some explanatory texts on larger screens.

plurals
  1. POQuery mysql complex
    primarykey
    data
    text
    <p>i want to ask something about query.. I have a mysql table and want to generate a little complex table..</p> <p>lets say i have these 3 table..</p> <p>Ship_terms</p> <pre><code>id | Name | Keterangan ------------------------- 1 | Installation | Instalasi 2 | Delivery | Pengiriman </code></pre> <p>Shipp_list</p> <pre><code>id | tipeShipp | namaShipp | Keterangan ---------------------------------------- 1 | 1 | KMA | Bla Bla Bla 2 | 1 | MTECH | Bla Bla Bla 3 | 2 | JNE | Bli Bli BLi </code></pre> <p>Shipp_price</p> <pre><code>id | idShipp | kota | price _______________________________ 1 | 1 | Jakarta | 0 2 | 2 | Jakarta | 0 3 | 3 | Bandung | 10000 4 | 3 | Jakarta | 5000 </code></pre> <p><strong>NOTES :</strong> ship_terms.id = shipp_list.tipeShipp , shipp_price.idShipp = shipp_list.id</p> <p>and what i exactly want is.. the result of the query (using 'kota = jakarta') is like this...</p> <pre><code>----------------- INSTALLATION ----------------- 1. KMA - 0 2. MTECH - 0 ----------------- DELIVERY ----------------- 1. JNE - 5000 </code></pre> <p>Anybody here can help me?? Thanks</p> <p>*<strong>UPDATE</strong></p> <p>here is my query :</p> <pre><code>{ /* Jika tersedia, lakukan pengambilan data */ /* Hitung berat */ $queryBerat = "SELECT SUM(berat)as berat FROM tmp_detail_jual WHERE username = '$_SESSION[uname]'"; $run = $db-&gt;query($queryBerat); $data_berat = $run-&gt;fetch(PDO::FETCH_ASSOC); $berat = $data_berat[berat]*$data_berat[jumBarang]; $beratTot = ceil($berat); /* ambil data shipping */ while($data_table = $cek-&gt;fetch(PDO::FETCH_ASSOC)){ $idShipp = $data_table[idShipp]; $harga = $data_table[price]; /* ambil nama kurir */ $querynama = "SELECT * FROM shipp_list where id='$idShipp'"; $getNama = $db-&gt;query($querynama); while($namaShipp = $getNama-&gt;fetch(PDO::FETCH_ASSOC)){ $nama = $namaShipp[namaShipp]; $keterangan = $namaShipp[keterangan]; $tipeShipp = $namaShipp[tipeShipp]; $idShippList = $namaShipp[id]; /* Cek tipe kurir */ $queryjenis = "SELECT * FROM ship_terms where id='$tipeShipp'"; $getJenis = $db-&gt;query($queryjenis); while($namaTerms = $getJenis-&gt;fetch(PDO::FETCH_ASSOC)){ $namaTerm = $namaTerms[name]; $keterangan = $namaTerms[keterangan]; /* Echo datanya */ echo '&lt;br&gt;'.$namaTerm.'&lt;br&gt;'; echo $nama.' - '.$harga*$beratTot; } } } } </code></pre> <p>But i got a result like this </p> <pre><code>----------------- INSTALLATION ----------------- KMA - 0 ----------------- INSTALLATION ----------------- MTECH - 0 ----------------- DELIVERY ----------------- JNE - 5000 </code></pre> <p>can you give a suggest so my query result will be like this</p> <pre><code>----------------- INSTALLATION ----------------- 1. KMA - 0 2. MTECH - 0 ----------------- DELIVERY ----------------- 1. JNE - 5000 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload