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
Przedstawiam kod:
<?php
/*---------------------------------------------------+
| Picture of the Day Infusion
| PHP-Fusion (c) 2005 Nick Jones
+----------------------------------------------------+
| Copyright (c) 2006 Adnan Ahmed
| info@theadnanahmed.com
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit <a href=\"http://gnu.org\" target=\"_blank\">http://gnu.org</a>
+----------------------------------------------------*/
/* Spolszczenie - jantom - <a href=\"http://jantom.info\" target=\"_blank\">http://jantom.info</a> */
//Article of the day
$presult = dbquery("SELECT * FROM ".$db_prefix."potd WHERE potd_type='A'");
$prows = dbrows($presult);
if ($prows != 0) {
$presult = dbquery("SELECT * FROM ".$db_prefix."potd WHERE potd_type='A'");
while ($pdata = dbarray($presult)) {
$lastchange = $pdata['potd_datestamp'];
$timediff = ($today - $lastchange)/3600;
if ($timediff > 24) {
$result=dbquery(
"SELECT * FROM ".$db_prefix."articles WHERE article_id!='".$pdata['potd_tid']."' ORDER BY RAND() LIMIT 1"
);
if(dbrows($result)==1){
openside("Artykuł dnia");
$data=dbarray($result);
<a href='".BASEDIR."readarticle.php?article_id=".$data['article_id']."' title='".$data['article_subject']."' class='side'>".trimlink($data['article_subject'], 100)."
</a>
</center>";
closeside();
}
$result = dbquery("UPDATE ".$db_prefix."potd SET potd_tid='".$data['article_id']."', potd_datestamp='".$timenow."' WHERE potd_id='".$pdata['potd_id']."'");
} else {
openside("Artykuł dnia");
$result=dbquery(
"SELECT * FROM ".$db_prefix."articles WHERE article_id='".$pdata['potd_tid']."'"
);
$data=dbarray($result);
<a href='".BASEDIR."readarticle.php?article_id=".$data['article_id']."' title='".$data['article_subject']."' class='side'>".trimlink($data['article_subject'], 100)."
</a>
</center>";
closeside();
}
}
} else {
$result=dbquery(
"SELECT * FROM ".$db_prefix."articles ORDER BY RAND() LIMIT 1"
);
if(dbrows($result)==1){
openside("Artykuł dnia");
$data=dbarray($result);
<a href='".BASEDIR."readarticle.php?article_id=".$data['article_id']."' title='".$data['article_subject']."' class='side'>".trimlink($data['article_subject'], 100)."
</a>
</center>";
closeside();
}
$result = dbquery("INSERT INTO ".$db_prefix."potd (potd_id, potd_type, potd_tid, potd_datestamp) VALUES('', 'A', '".$data['article_id']."', '".$timenow."')");
}
?>
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