hej,
mam problem z wyświetlaniem rekordów z bazy w rssie, mialem dac do klasy pętle while itd. no dalem tak jak myslalem ze to trzeba zrobic jednakze nie dziala

pomoze ktos?
oto kodzik:
@ patrzcie komentarze

<?php
require_once('rss1.php5');
$rss = new RssGenerator();
$rss->setPubDate('Tue, 20 Feb 2007 21:49:50 GMT');
$rss->setLanguage('pl-pl');
$rss->setCopyright('skorumpowany');
$rss->generateRssChannel('Kanał rss', 'http://www.skorumpowany.pl', 'Kanał RSS serwisu skorumpowany.pl');
//funkcyjka laczaca sie z baza
function baza_pol()
{
//$db = mysql_connect("xxx", "xxx", "xxx");
if (!$db)
{
echo "<b>NIE MA POLACZENIA Z BAZA DANYCH</b>"; }
/
if (!$db)
{
echo "<b>BRAK POLACZENIA Z BAZA DANYCH</b>"; }
}
include 'includes/pnAPI.php';
baza_pol();
$query1 = mysql_query("SELECT * FROM wiadomosci ORDER BY id DESC");
// robie petle tak jak kazal autor
{
$id = $rekord['id'];
$zajawka = $rekord['opis'];
$autor = $rekord['autor'];
$kategoria = $rekord['id_kat'];
if($kategoria == '1') {
$nazwa_kat = 'Motoryzacja';
} elseif ($kategoria == '2') {
$nazwa_kat = 'Motoryzacja2';
} elseif ($kategoria == '3') {
$nazwa_kat = 'Motoryzacja4';
} elseif ($kategoria == '4') {
$nazwa_kat = 'Motoryzacja5';
} elseif ($kategoria == '5') {
$nazwa_kat = 'Motoryzacja0';
}
//$opis = stripslashes (htmlspecialchars ($rekord['opis']));
//$opis = htmlspecialchars($rekord['opis']);
$tytul = $rekord['tytul'];
$link = pnVarPrepForDisplay(pnGetBaseURL() . "modules.php?op=modload&name=wiadomosci&cmd=read&id=$id");
$opis = pnVarPrepForDisplay
(strip_tags($zajawka));
// tu koniec petli ale...
}
// ...tu mi wyswietla tylko jeden rekord, jak klamre zamkne dalej czyli po tamtej
tablicy na dole o wyswietla mi ze DOM nie moze tworzyc wiecej obiektów :(
$rss->generateRssItem(''.$tytul.'', ''.$link.'', ''.$opis.'');
//$rss->generateRssItem('Title2', 'link2', 'afasfasff');
//$rss->generateRssItem('Title3', 'link2', 'afasfasff');
// $rss->generateRssItem('Title4', 'link2', 'afasfasff');
}
?>
plik z klasą:
<?php
class RssGenerator {
private $channelElement = array(); private $itemElement = array(); private $dom;
private $channel;
function __construct() {
}
function setLanguage($value) {
$this->ChannelElement[language] = $value ;
}
function setCopyright($value) {
$this->ChannelElement[copyright] = $value;
}
function setPubDate($value) {
$this->ChannelElement[pubdate
] = date(r
);
}else {
$this->ChannelElement[pubdate] = $value;
}
}
/**
* generateRssChannel()
* Funkcja generująca <channel>.
*
* @param $title - Tytul strumienia.
* @param $link - Adres url do strony "własciciela" strumienia.
* @param $description - Opis strumienia.
*
*/
function generateRssChannel($title, $link, $description) {
$this->channelElement[title] = $title;
$this->channelElement[link] = $link; $this->channelElement[description] = $description;
$this->dom = new DOMDocument('1.0', 'utf-8');
$mainNode = $this->dom->appendChild($this->dom->createElement('rss'));
$mainNode->setAttribute('version', '2.0');
$this->channel = $mainNode->appendChild($this->dom->createElement('channel'));
/*<channel>*/
/* Wymagane elementy */
$this->channel->appendChild($this->dom->createElement('title', $this->channelElement[title]));
$this->channel->appendChild($this->dom->createElement('link', $this->channelElement[link])); $this->channel->appendChild($this->dom->createElement('description', $this->channelElement[description]));
/* Opcjonalne elementy */
if(!empty($this->channelElement[language
])){ $this->channel->appendChild($this->dom->createElement('language', $this->channelElement[language]));
}
if(!empty($this->channelElement[copyright
])){ $this->channel->appendChild($this->dom->createElement('copyright', $this->channelElement[copyright]));
}
if(!empty($this->channelElement[pubdate
])){ $this->channel->appendChild($this->dom->createElement('pubdate', $this->channelElement[pubdate]));
}
}
/**
* generateRssItem()
* Funkcja generująca <item>.
*
* @param $title - Tytul strumienia.
* @param $link - Adres url itemu.
* @param $description - Opis strumienia.
*
*/
function generateRssItem($title, $link, $description) {
$this->itemElement['title'] = $title;
$this->itemElement['link'] = $link;
$this->itemElement['description'] = $description;
$item = $this->channel->appendChild($this->dom->createElement('item'));
$item->appendChild($this->dom->createElement('title', $this->itemElement[title]));
$item->appendChild($this->dom->createElement('link', $this->itemElement[link])); $item->appendChild($this->dom->createElement('description', $this->itemElement[description]));
}
function getRss() {
$this->dom->formatOutput = true;
return $this->dom->saveXML();
}
}
?>
moja znajomosc php jest na prawde nie duza, prosze o pomoc