I have a database and i want to extract result based on two table of database .say tablea and tableb . php searches for particular id in tablea and if it is found it has to do the work . it may be confusing here so i will present my tabela and tableb structure here.i am showing the details for a particular user which i am filtering by where clause
tablea
id userid
123 45
543 45
454 45
367 45
647 35
565 65
tableb
id jid
23 123
24 123
25 123
4535 543
4536 543
4506 454
4507 454
etc
we can see that for a particular userid there may be several values in mysql tablea and for each id of tablea there may be several values in tableb id.please note that based on tablea id i want to present all data of tableb and please note that tablea id and tableb jid are same but in tableb jid will appear several times based on the number of times that occurs and for every time there will be new id in tableb. i have don e this query but it results only one output . i want to display all .
$res1 = sql_query("SELECT id from tablea userid='{$user['id']}' order by id");
while ($row = sql_fetch_array($res1))
{
$phid=$row['id'];
{
$res2 = sql_query("select * from tableb where jid='{$phid}' order by id desc");
$row2 = sql_fetch_array($res2);
$d1 = $row2['id'];
echo ' '.$d1.' ';
}
}
This should make it. Although not very friendly.