please any one help me i want display images from mysql database to my web page...
i have no clear idea about that please help me..
i want script that will upload file and also display files in date vise.
And also i want display my images like my attachment. the images have separate style number so that i want display that number also..
before that tell me how to upload my images with that style number.

Dani AI

Generated

: the suggestions from and point in the right direction (accept an upload and keep a style/code value) and ’s layout shows how a grid can look. To make that work reliably and safely on a modern server, a few practical rules are important.

Storing image files on disk and saving metadata (original name, stored filename, style number, upload timestamp, MIME type, size) in the database is usually the easiest and fastest to scale; storing raw BLOBs in the DB is possible but often slower and harder to serve via CDNs. Always generate a unique stored filename (timestamp + random string, keep extension), never trust the user-supplied filename, and record the original name as metadata. Validate uploads server-side: check the PHP upload error code, verify content with finfo_file() or getimagesize(), enforce a whitelist of image MIME types and a size limit, and move files with move_uploaded_file() into a directory with script execution disabled. Use PDO or MySQLi with prepared statements rather than the deprecated mysql_* functions seen in ’s example.

Quick checklist and useful steps:

  1. HTML form must include enctype="multipart/form-data".
  2. Server-side: check $_FILES error, verify MIME/type, limit size, generate secure filename, call move_uploaded_file().
  3. Create/rescale thumbnails (GD or Imagick) for listings to avoid serving full-size images.
  4. Insert metadata (style number, stored filename, original name, UTC timestamp) with parameterized queries; index date and style-number columns for fast ordering/filtering.
  5. Serve thumbnails in the listing and link to full images; add Cache-Control/ETag headers for performance.

Small example of verifying MIME (use the Fileinfo extension):

$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime  = $finfo->file($_FILES['image']['tmp_name']);
if (! in_array($mime, ['image/jpeg','image/png','image/gif'])) { /* reject */ }

Common pitfalls: missing enctype, exceeding upload_max_filesize/post_max_size, incorrect directory permissions, or relying on $_FILES['name'] for the stored filename. PHP docs: file upload basics and finfo_file / getimagesize.

Recommended Answers

All 4 Replies

You should have a form which allows user to upload a picture and enter it's code.
Your form should include a upload button and a text field for a code. Your script should take the code entered and the image name, generate the current date and put these three data parts in to the different table columns of your database. (A structure for a table might be: {id, image_name, image_code, upload_date})
Your script for showing images should do a reverse thing - take information from database (sorted according the upload date) and then display it in your page.
I hope it helps a little bit...

Just store the uploaded area foler path with image name suffex with date and retrive accordingly...

Are u mean upload path as image code...

put this in your bdy. and make changes according to your database tables

<form name="form2"  method="post"  action="" >

<table align="center" border="0" bordercolor="#000033" width="90%" height="100%"   >
<tr>
<?

$select1=mysql_query("select * from product order by auto_id desc ");
$i=0;
while($fetch=mysql_fetch_array($select1))
{ 
if( $i<4)
{
		
?>
<td><table width="161" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="1" bgcolor="#C5DEA1"></td>
                        <td width="159" height="158" valign="top" background="images/box1_midbg.gif"><table width="150" border="0" align="center" cellpadding="0" cellspacing="0">
                          <tr>
                            <td height="19" colspan="2" class="heading1"><img src="images/arrow3.gif" width="9" height="9" /> <?=$fetch[productname]?></td>
                            </tr>
                          <tr>
                            <td width="85" height="114"><img src="admin/productimage/<?=$fetch[productimage]?>" width="79" height="94" /></td>
                           
                            
                          </tr>
                          
                        </table></td>
                        <td width="1" bgcolor="#C5DEA1"></td>
						</tr></table>
						</td>
						<?
						$i++;
						
						}
						if($i==4)
						{
					    echo "<tr>";
					    $i=0;
						 }
						 
						 
}
 
?>
</tr>
 

</table>
</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.