Well aside from the fact that it is syntactically incorrect. You aren't terminating the php blocks when you echo. Remember to end them with ?>. Aside from that, when you get the results find the number of results with mysql_num_rows then do a loop.
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
also, be careful to escape the quotes in the javascript block if necessary
scru
Posting Virtuoso
1,629 posts since Feb 2007
Reputation Points: 975
Solved Threads: 140