在段落中间插入图像从数据库检索的文本?

I have a MySQL table in which there are two columns , for text and for image separately. But when i retrieve those columns from database and display those on Site page I need to place the Image(from Image Column) at the middle of the paragraph text(which was retrieved from text column ). I have a separate Uploader that upload the image. I am using a text-editor (ckeditor) but it does not let me upload the pics from the computer so I had to do this.

I will Appreciate any suggestion or help.

enter image description here

content Body has the Paragraph Text and img_location has the image url.

<?php
 $conn = mysql_connect("localhost", "username", "password");
  if(!$conn)
  {
die('Could not connect '.mysql_error());
  }
  mysql_select_db("dbname");
  $res = mysql_query("select * from `tb_name`");
  while($v=mysql_fetch_array($res))
  {
    $name=$v['content_body'];
    $img=$v['img_location'];
    $count=strlen($name);
    for($i=0;$i < $count;$i++)
      {
       if($i == $count/2)
       echo "<img src='".$img."'/>"." ".$name[$i];
       else
       echo $name[$i];
      }
  }
 ?>