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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some help from a PHP person (might be easy for you)

Status
Not open for further replies.

fizzak

MIS
Feb 6, 2003
331
US
If you read the notation in this code it states what it does but in reverse to what I need. I want the earliest time to be displayed first not the latest. I'm not a coder but I can hack and slash a few things. I'm sure it's something simple but I just dont see it.

Code:
// view=images
if($_GET['view'] == "images")
{
	if($_GET['action'] == "masspublish")
	{
		$idz= $_POST['moderate_image_boxes'];
		// This is rather interesting since when multiple pictures have the same datetime stamp only the last one
		// will be shown. This means we have to construct single queries for each selected id and give them a
		// unique datetimestamp.
		// Since the latest image is displayed first we need to sort the idz because the lowest id have to be
		// published first.
		sort($idz);
		$minute_offset = 1;
		$current_hour = date("H");
		$current_minutes = date("i");
		$current_seconds = date("s");
		$ids = count($idz) - 1;
 		$query = "UPDATE ".$pixelpost_db_prefix."pixelpost SET datetime = ";
 		for ($i=0; $i < count($idz); $i++)
 		{
 			$datetimestamp = gmdate("Y-m-d H:i:s", mktime($current_hour, $current_minutes-($minute_offset*($ids-$i)), $current_seconds, date("m"), date("d"), date("Y"))+(3600 * $tz));
			$finalquery=$query."'".$datetimestamp."' WHERE id = '".(int)$idz[$i]."'";
 			$finalquery  = sql_query($finalquery);
 		}
 		$c = count($idz);
 		echo "<div class='jcaption confirm'>$admin_lang_imgedit_published  $c $admin_lang_imgedit_unpublished_cmnts</div>";
 	}
 
I am assuming you want the images to display the opposite direction (descending vs. ascending).

Look in the display section of the code that you have, and look for something along the lines of
<CODE>
$query = 'SELECT * FROM".$pixelpost_db_prefix."pixelpost ORDER BY *Date-Time-Stamp*' //..etc
</CODE>

Not sure exactly what it is going to look like for you, but you're going to have to change the SQL query to display based on the datestamp created in the code you referenced. Basically you're going to need to append a 'DESC' to the end of the query -

<CODE>
$query = 'SELECT * FROM".$pixelpost_db_prefix."pixelpost ORDER BY *Date-Time-Stamp* ORDER BY *Date-Time-Stamp* DESC'
</CODE>

This will make the displayed images start from newest to oldest, assuming that's what you're looking to do based on your question.

NOTE: Variables surrounded by */* are variables I made up completely.

Beware of hackers bearing executables. Happy Hunting. 'irc.2600.net'
 
EDIT** - It's not 'DESC', I meant ascending so sub 'ASC'. Sorry about that.

Beware of hackers bearing executables. Happy Hunting. 'irc.2600.net'
 
it's difficult to comment as we do not know what the shape of the form is, nor what is contained in the fields moderate_image_boxes.

but based on the code above, this code reverse sorts the $idz variable and iterates over the idz set updating the timestamp with successively increasing numbers of seconds.

Code:
<?php 
// view=images
if ($_GET['view'] == "images") {
    if ($_GET['action'] == "masspublish") {
        $idz = $_POST['moderate_image_boxes'];
        rsort($idz);
        $query = "UPDATE ".$pixelpost_db_prefix."pixelpost SET datetime = from_unixtime(%d) wgere id='%s'";
        for ($i = 0; $i < count($idz); $i++) {
			sql_query(vsprintf($query, array(strtotime("+ $i seconds"),$idz[$i])));
        }
        echo "<div class='jcaption confirm'>$admin_lang_imgedit_published " . count($idz) ." $admin_lang_imgedit_unpublished_cmnts</div>";
    }
}   
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top