CodeIgniter Forums
CSS styling for every blog from database - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CSS styling for every blog from database (/showthread.php?tid=55835)



CSS styling for every blog from database - El Forum - 11-12-2012

[eluser]echo sara[/eluser]
Hi,

I have been out of programming for a while. Slowly getting back into it. Right now i have created a small blog where i can submit a title and some body info. Once i click submit it post the info in the fields into the database and on the same page it show the info via ajax. The issue i have is when it submits to the database and shoots out via ajax; all the info (title, body) go into the same div and the div doesn't reproduce. so for every row of title i want a css styling to repeat it self instead now i just have all the rows of title going into the same div.

Code:
<div id="ajaxtitle"> </div>
<div id ="ajaxcomment"> </div>
<div id="titlebody"></div>



this is how i want it
Example:

Title ******** a box which is blue
Body


Title ******** another box which is blue
Body


Title ******** another box which is blue
Body


CSS styling for every blog from database - El Forum - 11-13-2012

[eluser]Unknown[/eluser]
please use the
Code:
&lt;?php json_encode ?&gt;
function.after that try to use this code for parsing json

Code:
success:function(response){
  //alert(response);
  var obj = jQuery.parseJSON(response);
  $.each(obj,function(index,val){
    var html= '<div id="ajaxtitle"><b>'+val.title+'</b><br/> '+val.ajaxcomment+'</div>';
    $("div[id=titlebody]").append(html);
  });                                      
}