1

I have 2 tables

Tbl A Cols : id nama kdwil

Tbl B Cols : id nama kdwil

Want show all data from that tables which kdwil is somevalue

So, I did

    $query2 = "SELECT * FROM a, b where a.kdwil=b.kdwil and a.kdwil='$kdwil'";
    $result2 = mysql_query($query2);
    while($row2 = mysql_fetch_array($result2)){ 
        echo "<label><input type='checkbox' value='".$row2['nama']."'>".$row2['nama']."</label>";

But returned no results.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0
$query2 = "SELECT * FROM a, b where a.kdwil=b.kdwil and a.kdwil='$kdwil'";
$result2 = mysql_query($query2);
while($row2 = mysql_fetch_assoc($result2)){ 
    echo "<label><input type='checkbox' value='".$row2['nama']."'>".$row2['nama']."</label>";

Use mysql_fetch_assoc instead.

Pyae Sone
  • 1,574
  • 2
  • 14
  • 18
  • thanks for the answer, but result printed why just from tbl B? can you explain this?thanks – Herlambang Permadi May 16 '17 at 01:04
  • Check these post. [mysql-fetch-array-mysql-fetch-assoc-mysql-fetch-object differences](http://stackoverflow.com/questions/1536813/mysql-fetch-array-mysql-fetch-assoc-mysql-fetch-object) – Pyae Sone May 16 '17 at 05:21