NTGre wrote:Yep is working but..... 😕
i v done it this way
$result_array[] = "<a href='index.php?cid=$cid&pid= ".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' />".$row[1]." ".$year = substr($row[3],0,4)."/".$month = ubstr($row[3],4,2)."/".$day = substr($row[3],6,2)."
</a>";
its OK ???
It's OK, but quite confusing. If you would assign $year, $month, $day before you built that string it may be more clear.
Based on the SQL I posted earlier:
$result = @mysql_query( "SELECT photo_id,photo_caption,photo_filename,
UNIX_TIMESTAMP(enddate) AS end, UNIX_TIMESTAMP(enddate) - UNIX_TIMESTAMP() as difference
FROM gallery_photos WHERE photo_category='".addslashes($cid)."'
LIMIT $from, $max_results");
You could write code similar to the following, using the date function to help format the date:
$photoId = $row[0];
$caption = $row[1];
$filename = $row[2];
$endDate = $row[3];
$result_array[] = "<a href='index.php?cid=$cid&pid=$photoId'><img src='$images_dir/tb_$filename' border='0' alt='$caption' />
$caption " . date("Y/m/d") . "</a>";
I've used used variable interpolation within that string to clean up a lot of the excess punctuation you were using and I've used the date() function to display the year, month, and day. Check the date function manual page for more details on the different formatting characters available to you and the string parsing section for more information on variable interpolation.
NTGre wrote:
and if its ok what i must do to display the countdown result instead of this???
".$year = substr($row[3],0,4)."/".$month = ubstr($row[3],4,2)."/".$day = substr($row[3],6,2)."
the countdown code is ....
$hour = 15; // 0 ... 24
$minute = 7; // 0 ... 60
$second = 5; // 0 ... 60
$month = 12; // 1 ... 12
$day = 8; // 1 ... 28/29/30/31
$year = 2005; // four digits
// time in seconds between now and then
$secdiff = mktime($hour,$minute,$second,$month,$day,$year) - time();
$a = floor ($secdiff/86400); // number of days
$b = floor ($secdiff%86400/3600); // + number of hours
$c = floor ($secdiff%86400%3600/60); // + number of minutes
$d = floor ($secdiff%86400%3600%60); // + number of seconds
For this section you could write something like:
$secdiff = $row[4];
$nDays = floor ($secdiff/86400); // number of days
$nHours = floor ($secdiff%86400/3600); // + number of hours
$nMinutes = floor ($secdiff%86400%3600/60); // + number of minutes
$nSeconds = floor ($secdiff%86400%3600%60); // + number of seconds
It's up to you how you want to name your variables, but something like $nDays is much more meaningful than $a and when you come back two your code in a few weeks you'll find that you'll be able to get a quicker grasp of it.
Anyways, your code from this point to the end should work just fine. Good luck,
Ryan