It's called Predictive search. Describing how to implement it would take a lot more text that this little box can contain. It'd also require knowledge of the e-commerce system you're using.
You're generating the table AFTER you've run through the loop multiple times. This means every row will be set to the same colour. You need to output the rows within the loop itself.
Something like this:
echo "<table width='200' border='2' cellspacing='0' cellpadding='0'>"
for ($i = 0; $i...
Right click in your browser and "view source". This will open the source code in notepad. If you edit it you can save it to your desktop and see your changes.