Jump to content

Recommended Posts

Hi there,

 

I've got a photography portfolio, and I've written some code to query an SQL database for any photos submitted within the last week. The code is as follows:

 

<?php 
$host="localhost";
$username="******"; 
$password="******"; 
$database="******"; 
$siteurl="http://www.oxidephoto.ca";
$connection = mysql_connect($host, $username, $password);
$db = mysql_select_db($database);
$q = "SELECT * FROM `plogger_pictures` WHERE DATE_SUB(CURDATE(),INTERVAL 14 DAY) <= date_submitted";
$result= mysql_query($q) or die
("Could not execute query : $q." . mysql_error());

while ($row=mysql_fetch_array($result))
{
$collection=$row["parent_collection"];
}

?>

 

This code exists within a while-db-has-pictures loop.

 

Also within this loop is the code to generate a 'NEW!' next to a new picture:

 

<?php if ($collection == plogger_get_collection_id()) {echo "NEW! ";} ?>

 

This works, technically, but the problem that I'm having is it does it to the most recent photo only, and if there's any others that apply (if I submit three in a day or something), they aren't highlighted.

 

I reckon that the problem is because $collection gets overwritten by the newest item grabbed each time, but I don't know how to correct this.  Any help would be greatly appreciated.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/82867-new-submissions/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.