create divs dynamically while php loop creating divs
<p>im new in jquery and get stacked in a issue and need help.</p>

<p>i have a sql query that retrieve ids and put them in array . i have a loop that create a div for each id in that array all in php. works fine.</p>

<p>on the other hand i have a javascript function doing the same with the same array and creating divs inside the div created with the above function all in jquery. </p>

<p>the first one show the picture of a users with the id.
the javascript one shows the name of users with the id.</p>

<p>the problem is jquery function only createme the div with all names within the first div created in the php loop.</p>

<p>i want both being created at the same time. i tried all i know and couldnt getit.</p>

<p>please help.</p>

<p>here is the code :</p>

<p>$receivers is the array containing the ids.
$totalreceivers is the count of the ids.</p>

<pre><code>function showfbnames() {

var receivers = &lt;? echo $receivers; ?&gt;;

var count = &lt;? echo $totalreceivers; ?&gt;;

for (var i = 0; i &lt; count; i++) {

var temparray = ["&lt;?php echo join("\", \"", $receivers); ?&gt;"];

FB.api(
        {
            method: 'fql.query',
            query: 'SELECT name FROM user WHERE uid='+temparray[i] 
        },
        function(resp) {
            $.each(resp, function(k,v) {

            $("#divfather").append("&lt;div class='tit' id ='fbname'&gt;"+(v.name)+"&lt;/div&gt;");
            //$("#fbname").html(v.name);

             })
        }
    );
    }
 }
</code></pre>

<p>the php loop creating divs :</p>

<pre><code>&lt;?for ($i = 0; $i &lt; $totalreceivers; $i++) {?&gt;
                &lt;script&gt;showfbnames()&lt;/script&gt;
            &lt;tr&gt;&lt;td&gt;
&lt;div style="width:100%; height:150px;overflow:auto;border-top:1px solid #c89cc1;border-bottom:1px solid #c89cc1;" id="divfather"&gt;
&lt;? echo "&lt;img src='https://graph.facebook.com/$receivers[$i]/picture' width='40' style='float:left'/&gt;";?&gt;


                    &lt;/div&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;? }    ?&gt;
</code></pre>
