d.fanning6388
05-06-2009, 08:54 PM
Struggling to get my head around this code, :confused:
I have two tables linked with a compound key table (applicants), the two tables I am using are job_index table and users table i am trying to get all the users who have 'applied' for job_id - 1.
$query = "SELECT * FROM applicants WHERE job_id='1'";
$result = mysql_query($query) or die ("Error in query");
if (mysql_num_rows($result)>0)
{
while ($row = @ mysql_fetch_array($result)) {
print $row["user_id"];
$user_id = $row["user_id"];
$query = "SELECT * FROM users WHERE id='$user_id'";
$result = mysql_query($query) or die ("Error in query");
if (mysql_num_rows($result)>0)
{
while ($row = @ mysql_fetch_array($result)) {
print "<b>" .$row["id"] . "</b><br/><br/>";
print "<b>" .$row["email"] . "</b><br/><br/>";
}}
}}
The result gets me three user_id's linked from the user table, but only ID - 1 is displayed
11
administrators
2
3
Any ideas?
I have two tables linked with a compound key table (applicants), the two tables I am using are job_index table and users table i am trying to get all the users who have 'applied' for job_id - 1.
$query = "SELECT * FROM applicants WHERE job_id='1'";
$result = mysql_query($query) or die ("Error in query");
if (mysql_num_rows($result)>0)
{
while ($row = @ mysql_fetch_array($result)) {
print $row["user_id"];
$user_id = $row["user_id"];
$query = "SELECT * FROM users WHERE id='$user_id'";
$result = mysql_query($query) or die ("Error in query");
if (mysql_num_rows($result)>0)
{
while ($row = @ mysql_fetch_array($result)) {
print "<b>" .$row["id"] . "</b><br/><br/>";
print "<b>" .$row["email"] . "</b><br/><br/>";
}}
}}
The result gets me three user_id's linked from the user table, but only ID - 1 is displayed
11
administrators
2
3
Any ideas?