HN-Community
[PHP] buat RSS mu sendiri yuk - Printable Version

+- HN-Community (https://hacker-newbie.org)
+-- Forum: Miscellaneous (https://hacker-newbie.org/forum-86.html)
+--- Forum: Coding/Programing (https://hacker-newbie.org/forum-19.html)
+---- Forum: Web Programing (https://hacker-newbie.org/forum-38.html)
+---- Thread: [PHP] buat RSS mu sendiri yuk (/thread-12593.html)



[PHP] buat RSS mu sendiri yuk - killerbyte - 02-17-2012

udah lama gk buat thread Cheer, hari ini ane mau ngeshare cata buat RSS xml sendiri menggunakan PHP Perimaho

langsung aja ke point pentingnya wakaka

pertama, buat percobaan kita pake aja localhost, buat yg blm punya bisa install XAMPP dulu Perimaho comot disini http://www.apachefriends.org/en/xampp.html
( download sesuai OS ya wakaka )
cara installnya banyak di google Bahagia

step 1, buka notepad atau pake text editor kesukaan kalian Cheer
step 2, copy + paste text dibawah
PHP Code:
<?php $db_host = "localhost"; //database host $db_username = "root"; //default XAMPP database username $db_pass = ""; //default XAMPP database password :) $db_name = "test"; //sesuaikan dengan database name kalian mysql_connect("$db_host","$db_username","$db_pass") or die ("nggak bisa connect pakde T.T"); //cantconnect mysql_select_db("$db_name") or die ("Databasenya yang mana pakde T.T"); //unknow database or non-exist database ?>
save ke folder htdocs xampp default windows (C://xampp/htdocs/) atau linux (/opt/lampp/htdocs/)
dengan nama config.php
step 3, copy + paste text dibawah
PHP Code:
<?php header("Content-type: application/xml"); // pasti udah tau donk fungsinya ^_^ include ("config.php"); // ngundang file config.php yang berisi isi config kaya database dan lain2 :D $query = "SELECT * FROM post ORDER BY id DESC"; //query yang bakal dijalanin di SQL ^_^ $result = mysql_query($query); // eksekusi query yang diatas, LoL echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <rss version=\"2.0\">\n <channel> <generator>RSS/1.0</generator> <title>Belajar Bareng KillerByte</title><!-- ganti dengan title web/blog agan2 :D --> <description>Pinter itu relatif tau :D</description><!-- ubah dengan description web/blog --> <link>http://haadiy.us/</link><!-- ubah dengan link web/blog agan2 :D --> <language>id</language><!-- ubah dengan bahasa web/blog agan2 :D --> <copyright>(c) 2012 R. Haadiy</copyright>\n";//ubah dengan copyright web/blog agan2 :p while($b = mysql_fetch_array($result)){ echo "<item><title>$b[1]</title> <link>http://website.com/post.php?p=$b[0]</link>//ubah dengan link web agan :D <pubDate>$b[3]</pubDate> <description>$b[2]</description> </item>\n"; } echo "</channel>\n</rss>"; ?>
save dengan nama rss.php
selesai dengan phpnya, sekarang kita lanjut kedatabasenya :D

step 4, buka http://localhost/phpmyadmin/
create database 'test'
trus klik SQL, masukan text dibawah, lalu klik Go
Quote:CREATE TABLE IF NOT EXISTS `post`
(
`id` int(25) NOT NULL AUTO_INCREMENT,

`title` text NOT NULL,

`content` text NOT NULL,

`date` date NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE=InnoDB;


INSERT INTO `post`
(`id`, `title`, `content`, `date`) VALUES

(1, 'title post 1 :p', 'content post 1 :p', '2012-02-15'),

(2, 'title post 2 :p', 'content post 2 :p', '2012-02-15'),

(3, 'title post 3 :p', 'content post 3 :p', '2012-02-15'),

(4, 'title post 4 :p', 'content post 4 :p', '2012-02-15'),

(5, 'title post 5 :p', 'content post 5 :p', '2012-02-16'),

(6, 'title post 6 :p', 'content post 6 :p', '2012-02-16');

step 5, we are done wakaka tinggal di cek di http://localhost/rss.php

cukup sekian thread ane hari ini Piktor kalo masih ada yang kurang jelas, bisa ditanya langsung disini Ganteng


RE: [PHP] buat RSS mu sendiri yuk - CMDhuman.Jr - 02-17-2012

aktifin xamp dulu ah, biar bisa kaya gitu Ganteng


RE: [PHP] buat RSS mu sendiri yuk - compLann - 02-17-2012

Mantab Mantab
keren bro... Bigsmile
bisa jelasin tentang tag2 XML gk??
aku masih bingung tntang XML.. Bingung


RE: [PHP] buat RSS mu sendiri yuk - killerbyte - 02-17-2012

Quote:Required channel elements



Title
Name of the RSS channel. For example, it can be the same as the website title.

Description.
Short description of the RSS channel.

Link
Link to the website the channel is related to.



Optional channel elements



Language
The language the channel is written in.

Copyright
RSS channel copyright information.

managingEditor
Email-address of the person responsible for the channel content.

webMaster
Email-address of the person responsible for channel publishing.

pubDate
Date of publishing according to the Date and Time Specification.

lastBuildDate
The last time the content of the channel changed.

Category
Specify one or more categories that the channel belongs to.

Generator
Title of the program used to generate the RSS feed.

Docs
Link to the RSS specification, used for creating the channel.

Ttl
Ttl means ‘time to live’ and specifies channel validity in minutes.

Image
Specify the image file (GIF, JPEG or PNG), which will be displayed in the RSS channel. The following parameters are accepted:

Title
This is usually the same text as RSS Title.

Description
Description of the image file, which will be displayed if the file is unavailable.

Link
Link to the page the channel is related to.

URL
URL of the JPEG, GIF or PNG file, which is linked to the RSS channel.

Width
Image width.

Height
Image height.

skipHours
The period during which RSS readers cannot check the channel for updates, in hours.

skipDays
The period during which RSS readers cannot check the channel for updates, in days.



Required item elements



Title
Item name of the RSS channel.

Description
Short description of the item.

Link
Link to the webpage containing the full description of the event.



Optional item elements



Author
Email-address of the message author.

Category
Item category.

Comments
Link to the webpage containing comments on the item.

Enclosure
This describes the media-object connected to the Item. The following parameters are supported:

URL
Link to the object file

Length
Size of the file in bytes.

Type
File type according to the MIME specification.

Guid
Unique string used to identify the item.

pubDate
Item date of publishing



RE: [PHP] buat RSS mu sendiri yuk - OrangBego - 02-22-2012

yuk mantap :D
yuk mantap :D
yuk mantap :D
yuk mantap :D
yuk mantap :D
yuk mantap :D

(biar jadi 40 gitu aja lah)