reading from 2 files through while loop

hi
i have two files

cat input.txt
123456| 43256
456482|5893242

cat data.txt
xv 123456 abcd dsk
sd 123456 afsfn dd
df 43256 asdf ff
ss 456482 aa
sf 5893242 ff ff
aa 5893242 aa aa

i need to read inputs from input.txt and find data for data.txt.
then i need to print them as a table as belw
(if we took 1st line from input)

123456 | 43256 |xv 123456 abcd dsk | df 43256 asdf ff
| |sd 123456 afsfn dd | ss 456482 aa

but i couldnt do it. Pleas help
i have the below script

Kind of close.

cat input.txt |
while IFS='|' read a b; do
  adata=`grep $a data.txt |head -1`
  bdata=`grep $b data.txt |head -1`
  echo $a '|' $b '|' $adata '|' $bdata
done 

The problems here are that (1) subsequent matches in data.txt are not matched, and (2) unmatched entries are not reported. To fix these, you need a more elaborate script with awk or perl. It CAN be done in shell script. Let's see where this gets you first.

Thank you dear otheus

it worked fine. I did it without ' head -1' since i need all the matches for both $a and $b

BUT..

if $a has more than 1 match in data.txt, it wont be printed in tablular form.
I need to export the results to Excel so the can more proccessed further.
lets say from data.txt we have more than 1 line matching $a, and output will be:

What i need now ,at least, is to have the output as follows:

|

so i can use text wizard in Excel to import it and keep it inshape.
Hope u got my point