Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP][PHP-Fusion] Zjęcie dnia
sebekzosw
post 16.05.2008, 13:06:18
Post #1





Grupa: Zarejestrowani
Postów: 437
Pomógł: 42
Dołączył: 16.04.2007

Ostrzeżenie: (0%)
-----


Witam! Chciałbym w PHP-Fusion zrobić wyświetlanie losowego artykułu! Znalazłem wtyczkę w którym mam skrypty, ale nie wiem co dorobić do bazy danych sadsmiley02.gif

Przedstawiam kod:

  1. <?php
  2. /*---------------------------------------------------+
  3. | Picture of the Day Infusion
  4. | PHP-Fusion (c) 2005 Nick Jones
  5. +----------------------------------------------------+
  6. | Copyright (c) 2006 Adnan Ahmed
  7. | info@theadnanahmed.com
  8. +----------------------------------------------------+
  9. | Released under the terms & conditions of v2 of the
  10. | GNU General Public License. For details refer to
  11. | the included gpl.txt file or visit <a href=\"http://gnu.org\" target=\"_blank\">http://gnu.org</a>
  12. +----------------------------------------------------*/
  13. /* Spolszczenie - jantom - <a href=\"http://jantom.info\" target=\"_blank\">http://jantom.info</a> */
  14.  
  15. //Article of the day
  16.  
  17. $presult = dbquery("SELECT * FROM ".$db_prefix."potd WHERE potd_type='A'");
  18. $prows = dbrows($presult);
  19.  
  20. if ($prows != 0) {
  21. $presult = dbquery("SELECT * FROM ".$db_prefix."potd WHERE potd_type='A'");
  22. while ($pdata = dbarray($presult)) {
  23.  
  24. $lastchange = $pdata['potd_datestamp'];
  25. $today = mktime(date("G"), date("i"), date("s"), date("m"), date("d"), date("Y"));
  26.  
  27. $timediff = ($today - $lastchange)/3600;
  28.  
  29.  
  30. if ($timediff > 24) {
  31. $result=dbquery(
  32. "SELECT * FROM ".$db_prefix."articles WHERE article_id!='".$pdata['potd_tid']."' ORDER BY RAND() LIMIT 1"
  33. );
  34. if(dbrows($result)==1){
  35. openside("Artykuł dnia");
  36. $data=dbarray($result);
  37. echo "<center>
  38. <a href='".BASEDIR."readarticle.php?article_id=".$data['article_id']."' title='".$data['article_subject']."' class='side'>".trimlink($data['article_subject'], 100)."
  39. </a>
  40. </center>";
  41. closeside();
  42. }
  43. $timenow = mktime(24-$settings['timeoffset'], 0, 0, date("m"), date("d")-1, date("Y"));
  44. $result = dbquery("UPDATE ".$db_prefix."potd SET potd_tid='".$data['article_id']."', potd_datestamp='".$timenow."' WHERE potd_id='".$pdata['potd_id']."'");
  45. } else {
  46. openside("Artykuł dnia");
  47. $result=dbquery(
  48. "SELECT * FROM ".$db_prefix."articles WHERE article_id='".$pdata['potd_tid']."'"
  49. );
  50. $data=dbarray($result);
  51. echo "<center>
  52. <a href='".BASEDIR."readarticle.php?article_id=".$data['article_id']."' title='".$data['article_subject']."' class='side'>".trimlink($data['article_subject'], 100)."
  53. </a>
  54. </center>";
  55. closeside();
  56. }
  57. }
  58. } else {
  59. $result=dbquery(
  60. "SELECT * FROM ".$db_prefix."articles ORDER BY RAND() LIMIT 1"
  61. );
  62. if(dbrows($result)==1){
  63. openside("Artykuł dnia");
  64. $data=dbarray($result);
  65. echo "<center>
  66. <a href='".BASEDIR."readarticle.php?article_id=".$data['article_id']."' title='".$data['article_subject']."' class='side'>".trimlink($data['article_subject'], 100)."
  67. </a>
  68. </center>";
  69. closeside();
  70. }
  71. $timenow = mktime(24-$settings['timeoffset'], 0, 0, date("m"), date("d")-1, date("Y"));
  72. $result = dbquery("INSERT INTO ".$db_prefix."potd (potd_id, potd_type, potd_tid, potd_datestamp) VALUES('', 'A', '".$data['article_id']."', '".$timenow."')");
  73.  
  74. }
  75.  
  76. ?>


Stąd można pobrać tą wtyczkę. Bardzo bym prosił, aby ktoś mi powiedział, jakie muszę stworzyć tabele i jakie muszą być zawartości bo nie za bardzo potrafię sobie poradzić!

Pozdrawiam, Sebekzosw

Ten post edytował sebekzosw 16.05.2008, 13:08:02
Go to the top of the page
+Quote Post
Cysiaczek
post 16.05.2008, 13:47:47
Post #2





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Złe forum- przenoszę na Gotowe rozwiązania -> Systemy CMS


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
sebekzosw
post 16.05.2008, 18:41:45
Post #3





Grupa: Zarejestrowani
Postów: 437
Pomógł: 42
Dołączył: 16.04.2007

Ostrzeżenie: (0%)
-----


Hmm, potrafiłby ktoś pomóc ;>
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 6.07.2025 - 09:06