I am in need of incrementing through a php array with the javascript variable "i" instead of where i have 0 in the $members array call

var i = 0;
    while (i<5)
        if (<?php echo json_encode($members[0]['department']); ?> ==  "CHE"){
                contacts.push({"NAME":"Sir Saula","TITLE":"John","CONTACT":"bab","RESEARCH":"Ph.D."});      


i doubt you can do it straightaway.. coz javascript wont be executed server side.. so while your php code is getting interpreted at server level you can't increment a javscript variable..