OK i see my mistake now.. $db_id is overwritten with the number of variable each array prints out.
But iam still left with the same problem, how then can i print $db_id with each corresponding $val.
I tried doing this doing something like this:
while (list($val) = each($names_array) and list($dbarray) = each($db_id_array)) {
but that doesnt work. Plz help.