Welcome Guest, Not a member yet? Register   Sign In
Display images from uploads folder using database
#6

[eluser]Rodrigo Graça[/eluser]
Try this:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset-UTF-8"&gt;
        
        &lt;style type="text/css"&gt;
            body {font-family: sans-serif;}
            #form {width: 675px; margin: auto; border: 2px solid #000; padding: 10px;}
        &lt;/style&gt;
        
    &lt;/head&gt;    
    &lt;body&gt;

    <div id="list_gallery">
<table name="list" id="list">
<thead>
   <tr>
    <th>
     ID
    
    </th>
<th>
     file name
    
    </th>
<th>
     image
    
    </th>
    
   </tr>
  </thead>
<tbody>
    &lt;?
    if(count($records)>0 && $rows!="")
    {
     foreach($rows as $row)
     {
    ?&gt;
    <tr id="&lt;?=$row-&gt;id?&gt;">
     <td>
      <span class="bosCheckbox tiptip">
       &lt;input type="checkbox" name="selection" value="1" /&gt;
       <span class="box" title="Check"></span>
      </span>
     </td>
                                        <td>&lt;?=$row->id?&gt;</td>
                                        
                                        
                                        <td>&lt;?=$row->file_name?&gt;</td>
                                        
                                        <td>
                                                <img src="&lt;?=base_url()?&gt;assets/uploads/&lt;?=$row-&gt;file_name?&gt;" border="0" title="&lt;?=$row-&gt;file_name?&gt;" alt="&lt;?=$row-&gt;file_name?&gt;" width="75" height="75">
                                              
                                        </td>
                                      
                                      
    </tr>


    &lt;?
    }
    }
   ?&gt;

     </tbody>
  </table>
</div>
    
        <h1 align="center">Add News</h1>
        <div id="form">
            &lt;?php
                echo form_open_multipart('../admin/create');
                    echo "<label>Title:</label><br />";
                    echo form_input('title') . "<br /><br />";      
            
                    echo "<label>Image:</label><br />";
                    echo form_upload('userfile') . "<br /><br />";
            
                    echo "<label>Content:</table><br />";
                    echo form_textarea('contents') . "<br /><br />";
                    
                    echo form_submit('', 'Submit');
                echo form_close();
            ?&gt;
        </div>
    &lt;/body&gt;
&lt;/html&gt;



Notes:

Maybe some erros.... (HTML or PHP)
Where is "file_name" you should change to the name of your fiel in the database. (Or change the database field name to "file_name" Big Grin )
All my files are .jpg or .png (if you want to display another type you need to change "img" tag....)


Messages In This Thread
Display images from uploads folder using database - by El Forum - 05-21-2012, 03:26 AM
Display images from uploads folder using database - by El Forum - 05-21-2012, 03:34 AM
Display images from uploads folder using database - by El Forum - 05-21-2012, 03:47 AM
Display images from uploads folder using database - by El Forum - 05-21-2012, 04:09 AM
Display images from uploads folder using database - by El Forum - 05-21-2012, 04:26 AM
Display images from uploads folder using database - by El Forum - 05-21-2012, 05:20 AM
Display images from uploads folder using database - by El Forum - 05-23-2012, 01:47 AM
Display images from uploads folder using database - by El Forum - 05-26-2012, 12:27 PM
Display images from uploads folder using database - by El Forum - 09-22-2012, 07:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB