A few possible problems:
Firstly (probably the main problem), in your PHP while-loop, you are retrieving $row using mysql_fetch_array() with the MYSQL_NUM bit-setting, yet later you seem to address a particular column in the row using a field name:
MYSQL_NUM means that each column is address by a number whereas MYSQL_ASSOC allows you to address a column by the field name. You may also want to consider using mysql_fetch_assoc() instead of mysql_fetch_array()...
Secondly, if $row["Id"] holds a string value in the DB, then you will need to include quotes around it in the js script:
Thirdly, I assume you already realize that the PHP will be run before this function is ever called... You will only be searching the db when the page is first loaded (it doesn't look like you were trying to plug in some js value into your query, which is why I assumed you already realized this possible issue).
Finally, you may consider using id[id.length] instead of 'p' to create the next item in your array... The length always gives 1+ the highest idex value in the current array, and it automatically updates when the array gains a new member.
If you want answers, write a smart question
, someone probably does know how...
Oh, and if you want to learn, STFW