Jump to content

alphawolf21

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

alphawolf21's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So I've gotten sub-boards established on my PHP/SQL forum, and they work great, with the exception of one thing. To check for last posts, I search my topics table for the most recent ID entry for that particular board. The problem with this is when these boards have sub-boards. I've added in a feature so members can click on "Expand" and it will show all sub-boards (along with their last posts), but while hidden, the only last post that shows is just of the parent board. How would I find which is the last post through all sub-boards of the parent board, and compare it/them to the parent board? Thanks
  2. <?php $doc = new DOMDocument(); $doc->load("rss/updates.xml"); $doc->formatOutput = true; include 'functions.php'; connect(); query("INSERT INTO updates(post,userid,subject,posted)VALUES('".addslashes($_POST["post"])."','".$_COOKIE["id"]."','".addslashes($_POST["subject"])."',CURRENT_TIMESTAMP)"); $n = mysql_insert_id(); loguser($_COOKIE["id"],"added an update to the site."); $update = sql("SELECT subject,post FROM updates WHERE id = '".$n."'"); $rss = $doc->createElement("rss"); $version = $doc->createAttribute("version"); $version->value = "2.0"; $nameSpace = $doc->createAttribute("xml:ns"); $nameSpace->value = "http://www.w3.org/2005/Atom"; $rss->appendChild($version); $rss->appendChild($nameSpace); $channel = $doc->createElement("channel"); $item = $doc->createElement("item"); $title = $doc->createElement("title"); $title->appendChild( $doc->createTextNode(stripslashes($update["subject"])) ); $link = $doc->createElement("link"); $link->appendChild( $doc->createTextNode("http://www.dreamspand.com/?act=updates") ); $post = $doc->createElement("description"); $post->appendChild( $doc->createTextNode(substr(stripslashes($update["post"]),0,80)."..") ); $item->appendChild($link); $item->appendChild($title); $item->appendChild($post); $channel->appendChild($item); $rss->appendChild($channel); $doc->appendChild($rss); $doc->saveXML(); $doc->save("rss/updates.xml"); echo "location.href='?act=updates';"; ?> This function writes and saves to an XML file, with one problem. It creates the RSS and channel elements each time I post an update into my database. How do I get it to just append the update elements to these tags without creating more? As in, how do I write within the rss/channel tags alone, and not just keep adding more of them to the file? My XML file looks like this: <?xml version="1.0"?> <rss version="2.0" xml:ns="http://www.w3.org/2005/Atom"> <channel> <item> <link>http://www.dreamspand.com/?act=updates</link> <title>t5</title> <description>f5..</description> </item> </channel> </rss> <rss version="2.0" xml:ns="http://www.w3.org/2005/Atom"> <channel> <item> <link>http://www.dreamspand.com/?act=updates</link> <title>t6</title> <description>f6..</description> </item> </channel> </rss> I want it to look like this: <?xml version="1.0"?> <rss version="2.0" xml:ns="http://www.w3.org/2005/Atom"> <channel> <item> <link>http://www.dreamspand.com/?act=updates</link> <title>t5</title> <description>f5..</description> </item> <item> <link>http://www.dreamspand.com/?act=updates</link> <title>t6</title> <description>f6..</description> </item> </channel> </rss> So if anyone has any ideas, I'd really appreciate it please. Otherwise this works fine, I'm just kinda lost.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.