Only confused as coders are! I have 5 of them myself. Will be 8 soonI believe you because I'm stupid.
Sessions sort strange .. or rather don't!
Moderator: Thorsten
not stupid!
Hi,
here's the sorting:
bye
Thorsten
here's the sorting:
Code: Select all
while (false !== ($dat = readdir($dir))) {
if ($dat != "." && $dat != ".." && strlen($dat) == 16 && !is_dir($dat)) {
$trackingDates[] = FileToDate($dat);
}
}
closedir($dir);
ksort($trackingDates);Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
to be sure ...
I am not quite sure where to put it!
Will you please post the complete code to replace with.
Will you please post the complete code to replace with.
Hi,
here it is:
bye
Thorsten
here it is:
Code: Select all
$dir = opendir(PMF_ROOT_DIR."/data");
$trackingDates = array();
while (false !== ($dat = readdir($dir))) {
if ($dat != "." && $dat != ".." && strlen($dat) == 16 && !is_dir($dat)) {
$trackingDates[] = FileToDate($dat);
}
}
closedir($dir);
ksort($trackingDates);
?>
<label class="left"><?php print $PMF_LANG["ad_stat_browse"]; ?>:</label>
<select name="day" size="1">
<?php
foreach ($trackingDates as $trackingDate) {
printf('<option value="%s"', date("Y-m-d", $trackingDate));
if (date("Y-m-d", $trackingDate) == strftime('%Y-%m-%d', time())) {
print ' selected="selected"';
}
print '>';
print date('Y-m-d', $trackingDate);
print "</option>\n";
}
?>
</select><br />Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
Hi,
the FileToDate() function is located in inc/functions.php and reads the date out of the file name and returns a unix timestamp.
I'll test it more on my box.
bye
Thorsten
the FileToDate() function is located in inc/functions.php and reads the date out of the file name and returns a unix timestamp.
I'll test it more on my box.
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
Hi,
change the
to
and it works here on my box.
bye
Thorsten
change the
Code: Select all
ksort($trackingDates);Code: Select all
sort($trackingDates);bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
php.net
http://www.php.net/manual/en/function.ksort.php
example code
However this array definition is not associative: I think the array does not have a key!
example code
Code: Select all
<?php
$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
ksort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val\n";
}
?> Code: Select all
$trackingDates = array();Hi,
okay, I will backport it to 1.5.8.
bye
Thorsten
okay, I will backport it to 1.5.8.
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
not quite
the sorting in the drop-down is OK, but now it sends the wrong date for lookup. 1969-12-31 is ALWAYS sent no matter which date I select from the dropdown! I think 1970-01-01 is first date in quite a lot of computer calendar-functions (a MySQL TIMESTAMP too). This is one day just before that.
Now this code gets too hairy to me!
If it works for you then I possibly just messed up the code. Available from snapshot build?
BTW: Looks like we got ourselves an additional dropdown too!

Now this code gets too hairy to me!
If it works for you then I possibly just messed up the code. Available from snapshot build?
BTW: Looks like we got ourselves an additional dropdown too!

Hi,
I'm working on that problem tomorrow. I'll watch a movie now.
bye
Thorsten
I'm working on that problem tomorrow. I'll watch a movie now.
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
Hi,
it's fixed with that code:
bye
Thorsten
it's fixed with that code:
Code: Select all
$dir = opendir(PMF_ROOT_DIR."/data");
$trackingDates = array();
while (false !== ($dat = readdir($dir))) {
if ($dat != "." && $dat != ".." && strlen($dat) == 16 && !is_dir($dat)) {
$trackingDates[] = FileToDate($dat);
}
}
closedir($dir);
sort($trackingDates);
?>
<label class="left"><?php print $PMF_LANG["ad_stat_browse"]; ?>:</label>
<select name="day" size="1">
<?php
foreach ($trackingDates as $trackingDate) {
printf('<option value="%d"', $trackingDate);
if (date("Y-m-d", $trackingDate) == strftime('%Y-%m-%d', time())) {
print ' selected="selected"';
}
print '>';
print date('Y-m-d', $trackingDate);
print "</option>\n";
}
?>
</select><br />Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
