Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 3 123 LastLast
Results 1 to 15 of 33
  1. #1
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Display last 5 Modified Pages

    PHP Code:
    <?php
    include 'opendb.php';
    $result mysql_query("SELECT * FROM map Limit 5") or die(mysql_error());

    while(
    $row mysql_fetch_array($result)){

    $list $row['Pathname'];

    echo 
    " - " .date("m d Y"filemtime($_SERVER['"/home/kochier/www/absurdity981.com/"$list']));
    echo 
    '<br />';
    }
     
    include 
    'closedb.php';
    ?>
    This is what I have so far, but all it displays is
    - 12 31 1969
    - 12 31 1969
    - 12 31 1969
    - 12 31 1969
    - 12 31 1969

    instead of the dates they were last modified. Any help would be nice as I'm stuck on this right now.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    PHP Code:
    <?php
    include 'opendb.php';
    $result mysql_query("SELECT * FROM map Limit 5") or die(mysql_error());

    while(
    $row mysql_fetch_array($result)){

    $list $row['Pathname'];

    echo 
    " - " .date("m d Y"filemtime($_SERVER["/home/kochier/www/absurdity981.com/" $list]));
    echo 
    '<br />';
    }
     
    include 
    'closedb.php';
    ?>
    remove ' inside $_SERVER and use '.' to add $list.

    regards

  • #3
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Alright I've tried that and it still displays 12 31 1969 as the modified date.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Why is this: $_SERVER["/home/kochier/www/absurdity981.com/" . $list] within you're $_SERVER superglobal? I'm taking a stab here, but I'm guessing that you don't actual add this index to the server superglobal, and if you do I'd suggest that you remove it. If anything, you may be wanting the PATH_TRANSLATED option, minus the SCRIPT_NAME part of it, so you can add you're own.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    PHP Code:
    while($row mysql_fetch_array($result)){

    $list $row['Pathname']; 
    you use mysql_fetch_array and try to retrive 'Pathname'. Use mysql_fetch_assoc instead.

    Edit: and check $list to be correct else filemtime will return 0

    regards

  • Users who have thanked oesxyl for this post:

    kochier (07-24-2008)

  • #6
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Thank you for your help, it's working now. Now is it possible to store this info in a table or array so I can sort it by the modified date?

    Code:
    <?php
    include 'opendb.php';
    $result = mysql_query("SELECT * FROM map") or die(mysql_error());
    
    while($row = mysql_fetch_assoc($result)){
    
    $list = $row['Pathname'];
    echo $list;
    
    echo " - " .date( filemtime("/home/kochier/www/absurdity981.com/" . $list));
    echo '<br />';
    }
     
    include 'closedb.php';
    ?>
    Last edited by kochier; 07-24-2008 at 06:14 PM.

  • #7
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by kochier View Post
    Thank you for your help, it's working now. Now is it possible to store this info in a table or array so I can sort it by the modified date?
    yes. filemtime return a unix timestamp so you can store and sort easy.
    it in a table as timestamp, maybe same table 'map', or fill an array with filemtime as values and $row['Pathname'] as key.

    PHP Code:
    <?php
    include 'opendb.php';
    $result mysql_query("SELECT * FROM map") or die(mysql_error());
    $flist = array();
    while(
    $row mysql_fetch_assoc($result)){
       
    $list $row['Pathname'];
       echo 
    $list;
       
    $fmtime filemtime("/home/kochier/www/absurdity981.com/" $list);
       
    $flist[$list] = $fmtime;
       echo 
    " - " .date("your format"$fmtime);
       echo 
    '<br />';
    }
    include 
    'closedb.php';
    ?>
    regards
    Last edited by oesxyl; 07-24-2008 at 06:30 PM.

  • #8
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Code:
    <?php
    include 'opendb.php';
    $result = mysql_query("SELECT * FROM map") or die(mysql_error());
    while($row = mysql_fetch_assoc($result)){
    $list = $row['Pathname'];
       $fmtime = filemtime("/home/kochier/www/absurdity981.com/" . $list);
       $flist[$list] = $fmtime;
    $insert = ("INSERT INTO map (Modified) 
    VALUES ('$fmtime'") or die('Failure to Insert data');
    mysql_query($insert) or die(mysql_error());
       echo " - " .date("d m Y", $fmtime);
    echo ' '; 
    echo $list;
    echo '<br />';
    }
    include 'closedb.php';
    ?>
    Is what I have right now, but how do I ensure it makes the modified path with the right pathname? Like if $pathname = index modified = timestamp(for index). Or am I better off trying to figure out how to sort the timestamp in the array and not worry about the database?

  • #9
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    in my opinion, the insert must contain info about pathname:
    PHP Code:
    $insert "insert into map (Modified, Pathname) values (".$fmtime.", '".$list."')"
    regards

  • Users who have thanked oesxyl for this post:

    kochier (07-24-2008)

  • #10
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Problem with that is Pathname is a primary key, so I get a duplicate error when I try this out. I need to simply have it modify the modified column for the selected pathname I believe. I was thinking something like
    Code:
    mysql_query("ALTER TABLE map MODIFY Modified $fmtime") or die (mysql_error());
    Though I think I'm using it fairly wrong at this point.
    Last edited by kochier; 07-24-2008 at 09:08 PM.

  • #11
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by kochier View Post
    Problem with that is Pathname is a primary key, so I get a duplicate error when I try this out. I need to simply have it modify the modified column for the selected pathname I believe.
    I don't know what is your case, but a solution could be to use something else as primary key, for example define a unsigned int field 'id' and use auto_increment for it

    regards

  • #12
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Code:
     $update = "UPDATE map SET Modified = '$fmtime' WHERE Pathname = '$list'" or die(mysql_error());
      mysql_query($update) or die(mysql_error());
    Though I still get the duplicate entry problem, even though I'm not trying to overwrite the Pathname entry.

    Ok giving up on mysql, I just want to be able to sort the array by the timestamp
    Code:
    $arry = array($fmtime);
    sort($arry);
    foreach ($arry as $key => $val) {
       echo " - " .date("d m Y", $val);
    }
    but it still isn't sorting it any differently.
    Last edited by kochier; 07-24-2008 at 09:45 PM.

  • #13
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by kochier View Post
    Code:
     $update = "UPDATE map SET Modified = '$fmtime' WHERE Pathname = '$list'" or die(mysql_error());
      mysql_query($update) or die(mysql_error());
    Though I still get the duplicate entry problem, even though I'm not trying to overwrite the Pathname entry.
    I'm not sure but I think that this will remain, once you have insert some rows in the table, untill you remove the duplicates.

    Ok giving up on mysql, I just want to be able to sort the array by the timestamp
    Code:
    $arry = array($fmtime);
    sort($arry);
    foreach ($arry as $key => $val) {
       echo " - " .date("d m Y", $val);
    }
    but it still isn't sorting it any differently.
    PHP Code:
    $arry = array();
    // insert items using something like:
    $arry[$list] = $fmtime;
    // use asort instead of sort to preserve the relation key values
    asort($arry);
    foreach (
    $arry as $key => $val) {
       echo 
    $key" - " date("d m Y"$val);

    regards

  • Users who have thanked oesxyl for this post:

    kochier (07-24-2008)

  • #14
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Code:
    <?php
    include 'opendb.php';
    $result = mysql_query("SELECT * FROM map") or die(mysql_error());
    while($row = mysql_fetch_assoc($result)){
    $list = $row['Pathname'];
       $fmtime = filemtime("/home/kochier/www/absurdity981.com/" . $list); 
    $arry = array();
    $arry[$list] = $fmtime; 
    asort($arry);
    foreach ($arry as $key => $val) {
       echo $key. " - " . date("d m Y", $val);
    echo '<br />';
    }
    }
    include 'closedb.php';
    ?>
    It still shows the entries as how they were inserted into the database, not by when they were modified.

  • #15
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    try this:
    PHP Code:
    <?php
    include 'opendb.php';
    $result mysql_query("SELECT * FROM map") or die(mysql_error());
    $arry = array();
    while(
    $row mysql_fetch_assoc($result)){
       
    $list $row['Pathname'];
       
    $fmtime filemtime("/home/kochier/www/absurdity981.com/" $list); 
       
    $arry[$list] = $fmtime;
    }
    asort($arry);
    foreach (
    $arry as $key => $val) {
       echo 
    $key" - " date("d m Y"$val);
    echo 
    '<br />';
    }
    include 
    'closedb.php';
    ?>
    regards

  • Users who have thanked oesxyl for this post:

    kochier (07-24-2008)


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •