Abdul Waheed Abdul Waheed - 9 months ago 34
HTML Question

How can i fetch multiple values with id and store in a variable

here is my code of eligible branches i am trying fetch multiple branches with one job id and store the array in a variable

and i want to send this in a mail body content as
for example it includes
for job id

i am selecting from
for multiple branches

$branchquery=$conn->query("SELECT * FROM r_job_branch where id_job=".$jobId) or die(mysqli_error());

i am selecting from
for multiple branch names

$bname=$conn->query("SELECT * FROM r_branch where id_branch=".$eligiblebranches) or die(mysqli_error());

i want to use that variable in this:

$message='<html><body><strong>Eligible Branches:</strong>'.$branches.'</body></html>';

Answer Source

Loop around putting out the branch name.

Using a JOINed query and making a guess at how your db connection is working:-


$message = '<html><body><strong>Eligible Branches:</strong>';

$branchquery=$conn->query("SELECT a.id_branch,
                            FROM r_job_branch a
                            INNER JOIN r_branch b
                            ON a.id_branch = b.id_branch
                            where id_job=".$jobId) or die(mysqli_error());

    $message .= $bres['branch_name']."<br />";
$message .= '</body></html>';