Hari Hari - 6 months ago 9
PHP Question

why are two query's inside one php tag not working

I have tried out some code were two mysql statement need to be executed, I don't have any syntax error though, but second mysql query is not working and not giving out any results. Please help me out am pretty new to this field if any mistake pardon me, thank you.

.php

<?php
$con = mysqli_connect("localhost", "*****", "*****", "******");
$query = ("SELECT * FROM profile");
$result = mysqli_query($con, $query);
while ($row = $result->fetch_assoc()) {
$query1 = ("SELECT vault_no FROM grp_tbl");
$result1 = mysqli_query($con, $query1);
while ($row1 = $result1->fetch_assoc()) {
if ($row1['vault_no'] !== $row['vault_no']) {
echo
'<div class = "chat-user-name"><span class="pull-right label label-primary"><input name="ppl" type="radio" value= "' . $row["via"] . '" "></span><div align="center"><input type="hidden" name="category" value="macro">
</div>
' . $row['via'] . ' </div>';
}
}
}
?>

Answer

Use like this, it may work

<?php
$con = mysqli_connect("localhost", "*****", "*****", "******");
$query = ("SELECT profile.* from profile left join grp_tblon profile.vault_no!=grp_tbl.vault_no where profile.vault_no!=grp_tbl.vault_no");
$result = mysqli_query($con, $query);
while ($row = $result->fetch_assoc()) {
            echo
            '<div class = "chat-user-name"><span class="pull-right label label-primary"><input name="ppl" type="radio" value= "' . $row["via"] . '" "></span><div align="center"><input type="hidden" name="category" value="macro">
                                                </div>
                                                ' . $row['via'] . ' </div>';
    }
}
?>