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.

1
  • You should be using PDO / MySQLi, mysql_* functions are deprecated. Commented May 15, 2017 at 23:44

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for the answer, but result printed why just from tbl B? can you explain this?thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.