I have two simple tables T1 and T2 both of datas coming by uploading. I want to display the file_name under a specific user_id.
T1
-------------------------
ID user_id admin_id
1 5 11
2 6 11
3 5 11
T2
--------------------------
ID user_id file_name
1 5 orange
2 6 apple
3 5 banana
My problem is it would display twice the echo as below, instead of only once. What is the best way to do this? Do I have to use inner join? Or is it possible to use only 2 for each loop. Sorry for a noob question.
orange banana
orange banana
Here is my sample:
$test1 = select user_id,admin_id FROM T1;
for($test1 as $key => $value)
{
$test2 = select user_id,file_type FROM T2;
foreach($test2 as $key => value2)
{
if(test1->user_id==test2->user_id)
{
$test2 = select user_id,file_name FROM T2;
echo $test2->file_name.'<br>';
}
}
}
PHP, but the your code example isn't valid PHP. Can you be clearer and fix these problems?