mysql - Display and retrieve image from database in PHP -


i want display image database displays name of image. need help. here code

submit.php

 <?php      $radio  = $_post['radiogroup1'];       $img_banner = $_files['bannerimage']['name'];      $target_file = "uploads/";       if(!empty($img_banner))      {       $errors = array();       $file_name = $_files['bannerimage']['name'];       $file_size = $_files['bannerimage']['size'];       $file_tmp = $_files['bannerimage']['tmp_name'];       $file_type = $_files['bannerimage']['type'];       $file_ext = strtolower(end(explode('.',$_files['bannerimage']['name'])));       $k  =  move_uploaded_file($file_tmp,"uploads/".$file_name);      }      $date = $_post['date'];      $qry_banner = "insert `banner_tbl`(`banner_img`, `date`) values  ('$img_banner','$date')";     $res_banner = mysql_query($qry_banner);     $banner_tbl_id = mysql_insert_id();       $sec_id = $_post['sectionid'];     $sec_active_image = $_post['activeimage'];     $sec_title = $_post['section_title'];         $total_sec = count($sec_id);       for($i=0;$i<$total_sec;$i++)      {       $qry_section1 = "insert `section_lt_tbl`(`banner_id`, `sectionid`,    `activeimage`, `sectiontitle`) values       ('$banner_tbl_id','$sec_id[$i]','$sec_active_image[$i]','$sec_title[$i]')";       $res_section1 = mysql_query($qry_section1);      $sec_tbl_id1 = mysql_insert_id();      $section_generated_id[] = $sec_tbl_id1;      }      $array_section_ids = array();     for($i=1;$i<=$radio;$i++)     {      $j = $i-1 ;         $array_section_ids[$i] = $section_generated_id[$j];      }        for($h=1;$h<=count($array_section_ids);$h++)         {        $news_ids_sec[$h] = $_post['sec_'.$h.'_new'];        $news_title_sec[$h] = $_post['sec_'.$h.'_title_news'];        $sec_1_desc[$h] = $_post['sec_'.$h.'_desc'];        $sec_1_newslink[$h] = $_post['sec_'.$h.'_newslink'];        $sec_1_news_url[$h] = $_post['sec_'.$h.'_news_url'];        $sec_1_news_img[$h] = $_files['sec_'.$h.'_news_img']['name'];        $temp_file[$h] = $_files['sec_'.$h.'_news_img']['tmp_name'];         $section  = $array_section_ids[$h];          for($c=0;$c<count($news_ids_sec[$h]);$c++)        {         $id =  $news_ids_sec[$h][$c];     //  $sec_id =  $array_section_ids[$h][$c];         $title=  $news_title_sec[$h][$c];         $desc =  $sec_1_desc[$h][$c];         $link =  $sec_1_newslink[$h][$c];         $url = $sec_1_news_url[$h][$c];         $img =  $sec_1_news_img[$h][$c][0];         $tmp_name = $temp_file[$h][$c][0];           $qry_news_insert = "insert `news_lt_tbl`(`newsid`, `news_sec_id`,     `newstitle`, `description`, `titleoflink`, `urlofnews`, `news_img`) values     ('$id','$section','$title','$desc','$link','$url','$img')";           $res_news = mysql_query($qry_news_insert);           $file_name = $img;          $file_tmp = $tmp_name;          $file_ext = strtolower(end(explode('.',$file_name)));          $k  =  move_uploaded_file($file_tmp,"uploads/".$file_name);        }       }       ?>      <?php         $qry_test = "select * `section_lt_tbl` sec_id = 162";         $res_tses = mysql_query($qry_test);        $arr = mysql_fetch_assoc($res_tses);       ?>       <?php       $query = "select `newsid`, `newstitle`, `description`, `titleoflink`,     `urlofnews`, `news_img` `news_lt_tbl` ";       $result_news = mysql_query($query);       $file_name = $img;       $file_tmp = $tmp_name;       $file_ext = strtolower(end(explode('.',$file_name)));       $k  =  move_uploaded_file($file_tmp,"uploads/".$file_name);      ?> 

and

      <table align="center" width="600">             <tr>            <tr>            <td bgcolor="#ffffff" valign="bottom" align="left"><a href="http://nrsadvisors.com/"><img border="0" src="http://www.nrsadvisors.com/email-images/mainlogo.jpg" alt="nrs advisors"/></a></td>            </tr>            <tr>                 <td style="border-top-width:2px; border-top-style:solid; border-top-color: #3e7dbd;" bgcolor="#dbdbdb"><img border="0"  src="http://www.nrsadvisors.com/email-images/banner-hero-image.png" alt="bannerimg" width="550" /><a name="featuredstartup" style="height:0;margin:0;padding:0"></a></td>               </tr>            <td bgcolor="#dbdbdb" align="center"><table border="0" cellpadding="0" cellspacing="0" width="550" align="center">            <tr>             <td width="25%"><a href="#featuredstartup"><img src="uploads/<?php     echo $arr['activeimage'] ?>_blue.jpg" width="125px" height="134px" /> </a></td>            <td width="25%"><a href="#healthcaredeals"><img src="uploads/<?php       echo $arr['activeimage'] ?>_grey.jpg" width="125px" height="134px" /></a></td>            <td width="25%"><a href="#healthcarenews"><img src="uploads/<?php     echo $arr['activeimage'] ?>_grey.jpg" width="125px" height="134px" /></a></td>            <td width="25%"><a href="#healthcaremarkets"><img src="uploads/<?php     echo $arr['activeimage'] ?>_grey.jpg" width="125px" height="134px" /></a></td>             </tr>            </table>            </td>            </tr>              <?php                    while ($row = mysql_fetch_array($result_news)) {            ?>            <table align="center" width="600">             <tr>             <span style="font-size:14px;line-height:17px;font-weight:normal;color:#333333">            <td align="left">            <span style="font-weight:bold">            <?php echo $row['newsid'] ?>            </span>            </td>            </span>            </tr>            <tr>            <td>             <span align='left' style='color:#3e7dbd;font-weight:bold'>             <span style='font-size:14px;line-height:17px;font-weight:normal;color:#333333'><span style='font-weight:bold'>             <?php echo $row['newstitle'] ?>             -</span><br><br>             </td>             </tr>             <tr>             <td><?php echo $row['description'] ?></td><br><br>             </tr>                       <tr>             <td>             <a href="<?php echo $row['urlofnews'] ?>" style='font-size:14px;line-height:17px;color:#3fc47b; text-decoration:none;'><?php echo $row['titleoflink'] ?></a></td><br><br>             </tr>             <tr>             <td><?php echo $row['news_img'] ?></td>             </tr>             </table>        <?php              }         ?> 

you need use img tag display image. this:

 <img src="your_upload_path/<?php echo $row['news_img'] ?>" /> 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -