<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
function getRandom() {
$("#random").hide();
$("#random").load("rsstoxml.php", '', callback);
}
function callback() {
$("#random").show();
setTimeout("getRandom();", 6000);
}
$(document).ready(getRandom);
</script>
</head>
<body>
<div id="random">
div content Here.......
</div>
</body>
</html>
Bangladeshi PHP and Javascript Programmer
Tuesday, February 8, 2011
rss feed to xml /Rss feed convert to xml format data
<?php
error_reporting(E_ALL);
// LOCATION OF THE FEED
$url = 'http://sports.espn.go.com/espn/rss/news';
//$url = 'http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/cricket/rss.xml';
// READ THE FEED
$xml = file_get_contents($url);
// CONVERT THE FEED TO AN OBJECT
$obj = SimpleXML_Load_String($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
// USE AN ITERATOR TO PRINT LINKS WITH THE ITEM TITLES
foreach ($obj->channel->item as $item)
{
$link = (string)$item->link;
$title = (string)$item->title;
$wrap_title= wordwrap($title, 62, "<br />");
$des = (string)$item->description;
$wrap_des = wordwrap($des, 79, "<br />");
if($url=="http://sports.espn.go.com/espn/rss/news")
{
$ini = strpos($wrap_des,"</a>");
$img_cut=substr($wrap_des,$ini);
}
else
{
$img_cut=$wrap_des;
}
echo "<div style='margin:0px auto;padding:0px;border:1px solid green;margin-bottom:20px;background:#CACACA;width:500px;'>";
echo "\n<a href=\"$link\">$wrap_title</a>";
echo "<br />";
echo "<div style='width:500px;'>$img_cut</div>";
echo "</div>";
}
?>
error_reporting(E_ALL);
// LOCATION OF THE FEED
$url = 'http://sports.espn.go.com/espn/rss/news';
//$url = 'http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/cricket/rss.xml';
// READ THE FEED
$xml = file_get_contents($url);
// CONVERT THE FEED TO AN OBJECT
$obj = SimpleXML_Load_String($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
// USE AN ITERATOR TO PRINT LINKS WITH THE ITEM TITLES
foreach ($obj->channel->item as $item)
{
$link = (string)$item->link;
$title = (string)$item->title;
$wrap_title= wordwrap($title, 62, "<br />");
$des = (string)$item->description;
$wrap_des = wordwrap($des, 79, "<br />");
if($url=="http://sports.espn.go.com/espn/rss/news")
{
$ini = strpos($wrap_des,"</a>");
$img_cut=substr($wrap_des,$ini);
}
else
{
$img_cut=$wrap_des;
}
echo "<div style='margin:0px auto;padding:0px;border:1px solid green;margin-bottom:20px;background:#CACACA;width:500px;'>";
echo "\n<a href=\"$link\">$wrap_title</a>";
echo "<br />";
echo "<div style='width:500px;'>$img_cut</div>";
echo "</div>";
}
?>
Wednesday, January 12, 2011
Display RSS with PHP
<?php header("Content-type: text/xml"); ?>
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; ?>
<rss version="2.0">
<channel>
<title>Website Title Here</title>
<?php
require_once("controller/dbconfig.php"); //change database configuration file
$con=new data(); //change class name and put your class
$connect=$con->connect(); //change function name and put your class
$query = "select * from video1 where status='2' order by date desc limit 5"; //change the query
$result=$con->execute($query);
while ($line = mysql_fetch_assoc($result))
{
$return[] = $line;
}
?>
<?php foreach ($return as $item) { ?>
<item>
<title><?php echo htmlentities($item['v_name']); ?></title> <!--Change table column name.[v_name] -->
<?php $id=$item['id']; ?> <!--Change table column name.[id] -->
<link><?php echo "http://yoursite.com/video.php?id=$id"; ?></link>
<description>
<![CDATA[
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width=20%>
<img src="<?php echo htmlentities($item['images']); ?>" width="80" height="80" /> <!--Change table column name.[images] -->
</td>
<td width=80% valign=top><?php echo htmlentities($item['description']);?></td> <!--Change table column name.[description] -->
</tr>
</table>
]]></description>
</item>
<?php } ?>
</channel>
</rss>
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; ?>
<rss version="2.0">
<channel>
<title>Website Title Here</title>
<?php
require_once("controller/dbconfig.php"); //change database configuration file
$con=new data(); //change class name and put your class
$connect=$con->connect(); //change function name and put your class
$query = "select * from video1 where status='2' order by date desc limit 5"; //change the query
$result=$con->execute($query);
while ($line = mysql_fetch_assoc($result))
{
$return[] = $line;
}
?>
<?php foreach ($return as $item) { ?>
<item>
<title><?php echo htmlentities($item['v_name']); ?></title> <!--Change table column name.[v_name] -->
<?php $id=$item['id']; ?> <!--Change table column name.[id] -->
<link><?php echo "http://yoursite.com/video.php?id=$id"; ?></link>
<description>
<![CDATA[
<table width="80%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width=20%>
<img src="<?php echo htmlentities($item['images']); ?>" width="80" height="80" /> <!--Change table column name.[images] -->
</td>
<td width=80% valign=top><?php echo htmlentities($item['description']);?></td> <!--Change table column name.[description] -->
</tr>
</table>
]]></description>
</item>
<?php } ?>
</channel>
</rss>
Sunday, October 31, 2010
Best PHP Forum Lists
1. http://www.daniweb.com/forums/
2. http://www.codingforums.com/
3. http://www.phpbuilder.com/board/member.php?u=205686&tab=aboutme&simple=1
4. http://www.sitepoint.com/forums/member.php?u=409050
5. http://amit-kuetcse2k5.myopenid.com/
6. http://stackoverflow.com/users/492656/amit-kuetcse2k5
2. http://www.codingforums.com/
3. http://www.phpbuilder.com/board/member.php?u=205686&tab=aboutme&simple=1
4. http://www.sitepoint.com/forums/member.php?u=409050
5. http://amit-kuetcse2k5.myopenid.com/
6. http://stackoverflow.com/users/492656/amit-kuetcse2k5
Wednesday, September 8, 2010
How to convert bangladeshi currency from numbers to words in PHP
<?php
function convert_number($number)
{
if (($number < 0) || ($number > 999999999))
{
throw new Exception("Number is out of range");
}
$Gn = floor($number / 1000000); /* Millions (giga) */
$number -= $Gn * 1000000;
$kn = floor($number / 1000); /* Thousands (kilo) */
$number -= $kn * 1000;
$Hn = floor($number / 100); /* Hundreds (hecto) */
$number -= $Hn * 100;
$Dn = floor($number / 10); /* Tens (deca) */
$n = $number % 10; /* Ones */
$res = "";
if ($Gn)
{
$res .= convert_number($Gn) . " Million";
}
if ($kn)
{
$res .= (empty($res) ? "" : " ") .
convert_number($kn) . " Thousand";
}
if ($Hn)
{
$res .= (empty($res) ? "" : " ") .
convert_number($Hn) . " Hundred";
}
$ones = array("", "One", "Two", "Three", "Four", "Five", "Six",
"Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen",
"Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen",
"Nineteen");
$tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty",
"Seventy", "Eigthy", "Ninety");
if ($Dn || $n)
{
if (!empty($res))
{
$res .= " and ";
}
if ($Dn < 2)
{
$res .= $ones[$Dn * 10 + $n];
}
else
{
$res .= $tens[$Dn];
if ($n)
{
$res .= "-" . $ones[$n];
}
}
}
if (empty($res))
{
$res = "zero";
}
return $res;
}
$cheque_amt = 8747484 ;
try
{
echo convert_number($cheque_amt)." BDT";
}
catch(Exception $e)
{
echo $e->getMessage();
}?>
Subscribe to:
Comments (Atom)