Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display member image for 24 from date and time member signs up

Status
Not open for further replies.

cs7536

Programmer
Apr 20, 2003
130
0
0
US
I am looking to display a persons image for 24 from the date and time that they initialy sign up on my site. I currently have the script displaying all new members until 12 midnight then it removes all users but I need it to expire individualy based on a 24 hour period instead of all at midnight.

any help would be apprciated

thanks in advance

can't we all just get along

Max
 
do you get your image pointers from a database? if so just create another field and put in the unix timestamp of the joining datetime.

Code:
$dt = strtotime("now");

then you can use your sql to retrieve only those images that you want

Code:
$compare = strtotime("- 24 hours");

$sql  = "select image from imagetable where datejoined > $compare";

if you are not able to use a database but are instead using the filesystem, you may be able to use some of the date information in the filesystem but to make you app cross browser compatible i'd suggest creating a text file into which you programmatically insert each filename and the timestamp and then test against it.

Code:
//manage the upload
$fh = fopen ("imagedb.txt", "a+");
fwrite ($fh, $_FILES['uploadedfile']['filename'] . ",".strtotime("now")."\n");
fclose ($fh);

and then to test
Code:
$compare = strtotime("- 24 hours");
$newfile ="";
$fh = fopen ("imagedb.txt", "rb");
while (($data = fgetcsv($fh, 2048, ",")) !== FALSE):
   if ($data[1] > $compare):
      $imagestoshow[] = $data[0];
      $newfile .= "{$data[0]},{$data[1]})\n";
   endif;
endwhile;
fclose($fh);
//all the images to show are in $imagestoshow
foreach ($imagestoshow as $fnam):
  echo "<img src=\"$fnam\" /><br/>";
endforeach;
//now scrub the db file and fill it with only the items that are still fresh.
$fh =fopen("imagedb.txt", "wb");
fwrite ($fh, $newfile);
fclose ($fh);
}

p.s. i have not tested the above for errors.
 
cool thanks, much apreciated.

can't we all just get along

Max
 
you're welcome. post back if it does not do what you're after.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top