load("feedit.xml") ) { print "xml-virhe"; exit; } $user = trim($_REQUEST["user"]); /* CREATE TABLE Channel ( FeedURL VARCHAR(1024) NOT NULL PRIMARY KEY, title VARCHAR(1024) NOT NULL, link VARCHAR(1024) NOT NULL, description VARCHAR(16384) NOT NULL, ttl INTERVAL DEFAULT '5 minutes', lastBuildDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ; */ if ( $user != "" ) { $sql = $dbh->prepare(' SELECT FeedURL, title, link, description FROM Channel, UserChannel WHERE UserChannel.UserID = :user AND UserChannel.Channel = Channel.FeedURL '); if ( !$sql ) { print_r( $dbh->errorInfo() ); print("tietokantavirhe"); } $sql->bindParam(":user", $user); } else { $sql = $dbh->prepare('SELECT FeedURL, title, link, description FROM Channel'); if ( !$sql ) { print_r( $dbh->errorInfo() ); print("tietokantavirhe"); } } $ok = $sql->execute(); if ( !$ok ) { print_r( $sql->errorInfo() ); print("SQL-suorituksessa tapahtui virhe."); } else { while ( $p = $sql->fetch(PDO::FETCH_ASSOC)) { $option = $doc->createElement("option"); $option->setAttribute("value", $p["FeedURL"]); $option->setAttribute("title", $p["description"]); $txt = $doc->createTextNode( $p["title"] ); $option->appendChild( $txt ); $doc->documentElement->appendChild($option); } print $doc->saveXML(); } ?>