I am trying to push to the javascript array after looping 200 times through the member array to push every member that matches the department selected description into the javascript array., However it fails

<? $i = 0 ;
    while( $i < 200)
        {

            if ($members[$i]['department'] == $depttts){
             break;
                  echo "<script type='text/javascript'>contacts.push({"NAME":"SirSaula","TITLE":"John","CONTACT":"bab","RESEARCH":"Ph.D."});</script>";

            }
            else {
              $i++;
            }

        }

    ?> 

Recommended Answers

All 3 Replies

Hi Sir Suala,

It seems to me that the break command will cause the echo to be skipped every time.

Forgot to edit the break line out ignore it

Member Avatar for diafol

I don't think you can mix it like this. I'd place all the php stuff into a php array then json encode it and push that into js.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.