I've been working on this code for some times and I want a better way than I've written. I want to get any of the column where they id are 1 and compare them one by one with table2, and echo those which are the same:
$user_id="1";
$job_list = mysql_query("SELECT * FROM tbl_job WHERE user_id=$user_id");
while ($row2 = mysql_fetch_row($job_list)) {
$a[]=$row2[0];
$b[]=$row2[1];
$c[]=$row2[2];
}
// echo $a[0] => john
// echo $a[1] => sara
and this code compares them one by one and create array:
$job_list3 = mysql_query("SELECT * FROM tbl_job_2 WHERE
name= '$a[0]' AND
job= '$b[0]' AND
location='$c[0]' ");
while ($row3 = mysql_fetch_row($job_want_list3)) {
$aa[]=$row3[0];
$bb[]=$row3[1];
$cc[]=$row3[2];
}
but I think this is the wrong way! Is there a better way? Thanks
Edit:
For better understanding: I get the output of the second code and put it in the array. But that's the wrong way, because I have to print a lot of variables. I think in some way I shold use WHILE
command.