Jump to content

Image Counting


Guest

Recommended Posts

You could do something like this. Name your file something like:

 

<?php
/* Database structure:
--------------------------------
| id | mime | filename | views |
--------------------------------
*/

$config = array(
	'db_host'		=> "localhost",
	'db_user'		=> "root",
	'db_pass'		=> "",
	'db_name'		=> "your_database",
	'image_path'	=> "/home/somebody/images/", // needs trailing slash!
);

$db_link = @mysql_connect($config['db_host'], $config['db_user'], $config['db_pass']);
@mysql_select_db($config['db_name'], $db_link) or die();

$query = @mysql_query("SELECT * FROM images WHERE id='".intval($_GET['image_id'])."' LIMIT 1", $db_link);
if(@mysql_num_rows($query) <= 0)
{
die();
}
else {
$image_info = @mysql_fetch_assoc($query);
@header("Content-type: {$image_info['mime']}");
@readfile($config['image_path'].$image_info['filename']);
}

@mysql_close($db_link);
?>

Link to comment
https://forums.phpfreaks.com/topic/36692-image-counting/#findComment-175010
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.