I have contact list which contains (checkbox,firstname,lastname,phone). I am creating this list using html divs, and I calling the data from the database as you can see below ($res_contactlist) and put each value in the appropriate div.
This process is not practical when refreshing the page, it makes the page very slow.
I heard that jQuery can help a lot in performing this process. Would you please help me how to implement this logic in jQuery?
This is the code where I am drawing the divs with data from DB.
<?
if ($res_contactslist) {
while($contacts_row = mysql_fetch_assoc($res_contactslist)) {
print'<div class="headings_01">
<div class="checkbox_01"><input name="contact_id" id="selectedcontacts" type="checkbox" value="'.$contacts_row['contact_id'].'" style="margin-top:0px;" /></div>
<div class="firstname_01" name="fname">|'.$contacts_row['contact_id'].'|'.$contacts_row['firstname'].'</div>
<div class="lastname_01" name="lname">'.$contacts_row['lastname'].'</div>
<div class="group_01">G1</div>
<div class="mobile_nmbr_01" name="phone" id="phone">'.$contacts_row['phone'].'</div>
</div>';
}
}
If the problem is that you need to refresh all the page, you will need to create a service in your server that does all the logic and returns something like a json of what you want to show and then, via jquery call it and manipulate the html with the new data.
This tutorial will be very useful for you: http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/
Hope it helps