|
PCCS MySQLDatabase Admin Tool version 1.3.4
|
/ -> mysqldb_makerdf.php
1 <?php
2 $host ="localhost";
3 $login = "root";
4 $password = "simple";
5 $db = "eitsdb";
6 $rdfoutputfile = "myrdf.rdf";
7 $SQLText = "SELECT news_id, news_story_title,
8 news_story_active, news_story_test,
9 news_story_author, news_story_html
10 FROM news
11 WHERE news_story_active = 1
12 ORDER BY news_story_date desc LIMIT 10";
13
14
15
16 if (!mysql_connect($host,$login,$password)) {
17 print "No connection made\n";
18 exit();
19 }
20 mysql_select_db( $db ) or die ( "Errorng the database\n" );
21 $result = mysql($db, $SQLText);
22
23
24 $rdf_title = "MySite News";
25 $rdf_link = "http://eitsdev.hou.rohmhaas.com";
26 $rdf_descr = "News Feed From My Site";
27 $rdf_lang = "en-us";
28
29
30 if (!$file=fopen($rdfoutputfile,w)) {
31
32 print "could notthe file";
33
34 } else {
35
36 /*
37 Print header, doctype, etc..
38 */
39 fputs ( $file, "<?xml version=\"1.0\" encoding=\"$rdf_encoding\"?>\n\n" );
40
41 fputs ( $file, "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n" );
42
43 fputs ( $file, "<rss version=\"0.91\">\n\n" );
44 fputs ( $file, "<channel>\n" );
45
46
47
48
49 fputs ( $file, "<title>$rdf_title</title>\n ");
50 fputs ( $file, "<link>$rdf_link</link>\n");
51 fputs ( $file, "<description>$rdf_descr</description>\n");
52 fputs ( $file, "<language>$rdf_lang</language>\n\n");
53
54
55 /*
56 Loop for printing the 10 items.
57 */
58
59 while ($row=mysql_fetch_row($result)) {
60
61 $titled = $row[1];
62 // $newsd = $row[2];
63 $linked = $row[0];
64
65 fputs ( $file, "<item>\n" );
66
67 $title = "<title>" . htmlspecialchars(stripslashes($titled)) . "</title>\n";
68 $link = "<link>http://eitsdev.hou.rohmhaas.com/test/news.php?article=" . htmlspecialchars(stripslashes($linked)) . "</link>\n";
69 // $news = "<description>" . htmlspecialchars(stripslashes($newsd)) . "</description>\n";
70
71 fputs ( $file, $title );
72 fputs ( $file, $link );
73 // fputs ( $file, $news );
74
75 fputs ( $file, "</item>\n\n" );
76
77 }
78
79
80 }
81
82 fputs ( $file, "</channel>\n");
83 fputs ( $file, "</rss>\n");
84
85 fclose( $file );
86 // }
87 ?>
| |