SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Go to: http://www.icosmoss.com/ and you see this project tracker (New Source Codes). What I want to do is automate this updater with PHP. It should display the 5 newest files by grabbing their date in the database table.

    It should sort the result by date; the latest comes to the top.

    How can I do this? Thanks

    ------------------
    Matthias Hagemann - matt@icosmoss.com
    Need some source code?
    icosmoss.com - The Open Source Community

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont know much PHP But this is the logic of your problem.

    A. change your SQL statement to have this "ORDER BY DATE" after the where clause. That will display them in the order you wish.

    B. to only grab 5 unless PHP has a specific function to do that do it like you'd do a for while loop. Make a counter variable and do a check and see if its less than or equal to 5, if it is you display one result, add 1 to counter, start at top etc.

    Chris

  3. #3
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote/font><HR>Originally posted by aspen:
    I dont know much PHP But this is the logic of your problem.

    A. change your SQL statement to have this "ORDER BY DATE" after the where clause. That will display them in the order you wish.
    Chris
    <HR></BLOCKQUOTE>

    I n the ORDER BY date statement the latest is at the bottom, I would like to have it turned around.

  4. #4
    SitePoint Member
    Join Date
    Jul 2000
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Add "DESC" to turn it around:

    ORDER BY datecolumn DESC


    ------------------
    Antti
    Huotari.com/antti/
    LinuxWebDevNews.com

  5. #5
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is so cool! Thanks alot. BTW the trick was to add this code after the query:

    "SELECT something FROM table ORDER BY date DESC LIMIT 0,5".

    By renaming the index file to the php3 extension the current date dissappears and the polls. Since now I've used this code for the date:

    &lt;!--#config timefmt="%A, %B %d %Y" --&gt;&lt;!--#echo var="DATE_LOCAL" --&gt;

    and this for the pollings:

    &lt;!--#exec cgi="cgi-bin/somefile.pl" --&gt;

    How can I translate it into PHP?

    [This message has been edited by DIMA (edited August 12, 2000).]

  6. #6
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm already successful with the date code. The only thing now is executing the CGI-script. How can I do this?

    I tried this but it doesn't help:

    &lt;?php exec("cgi-bin/somefile.pl"); ?&gt;

    [This message has been edited by DIMA (edited August 12, 2000).]

  7. #7
    SitePoint Member
    Join Date
    Jul 2000
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote/font><HR>&lt;?php exec("cgi-bin/somefile.pl"); ?&gt;<HR></BLOCKQUOTE>

    That should work. So, the problem might be that (just guessing):

    1) It doesn't find the file
    -&gt; check web server's error log
    -&gt; try putting the full path to the .pl file

    2) You are using php in safe mode (safe_mode=On)
    -&gt; then you can only run programs in the safe_mode_exec_dir
    -&gt; check that with phpinfo()

  8. #8
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote/font><HR>Originally posted by antti:
    That should work. So, the problem might be that (just guessing):

    1) It doesn't find the file
    -&gt; check web server's error log
    -&gt; try putting the full path to the .pl file

    2) You are using php in safe mode (safe_mode=On)
    -&gt; then you can only run programs in the safe_mode_exec_dir
    -&gt; check that with phpinfo()
    <HR></BLOCKQUOTE>


    1)
    -&gt; nothing is shown at that place
    -&gt; still doesn't work

    2)
    -&gt; that's a little too high-level Can you give me some code for this? Thanks.

  9. #9
    SitePoint Member
    Join Date
    Jul 2000
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote/font><HR>2)
    -&gt; that's a little too high-level <HR></BLOCKQUOTE>



    <BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>&lt;?php phpinfo(); ?&gt;[/code]

    Search for a line that reads: safe_mode

    safe_mode_exec_dir description (from the PHP manual):
    "If PHP is used in safe mode, system() and the other functions executing system programs refuse to start programs that are not in this directory."

  10. #10
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the line safe_mode it sais: 0
    And the safe_mode_exec_dir is empty

    Hmmm...

  11. #11
    SitePoint Member
    Join Date
    Jul 2000
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote/font><HR>In the line safe_mode it sais: 0
    And the safe_mode_exec_dir is empty<HR></BLOCKQUOTE>

    So, that is not the problem. You are certain that the CGI-script works and has the proper permissions? I'm running out of ideas...

  12. #12
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The script itself runs well, since I had it in the .shtml version. The only problem is that it doesn't run with the .php3 extension. I got a hint to look at this page:
    http://www.php.net/manual/function.virtual.php

    Currently I can't check it because my DSL connection isn't working so I can't upload the modified file to test it. I'll keep you updated...

  13. #13
    SitePoint Member
    Join Date
    Jul 2000
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you use mysql check the LIMIT statement to get only 5 results.

  14. #14
    Almeaty Member
    Join Date
    Jul 2000
    Location
    Nowhere
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks to you all!

    The CGI-SSI thing works just fine. I'm really glad that my DSL connection is working again. Whew.

    ------------------
    Matthias Hagemann - matt@icosmoss.com
    Need some source code?
    icosmoss.com - The Open Source Community


Bookmarks

Posting Permissions

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