Archive for May 2008
My Blog Fetcher…
Blog fetcher is program in PHP that i have made to fetch my blog heading titles (topics) and also the dates and categories. But this program is applicable only for my particular blog not for other blogs. So that I have used file handling for reading data of My blog. Blog fetcher is similar to the concept of RSS , But still it is not RSS. It catches the html tags of my blog and reads data of that tag and prints the data. Output is bellow…
php code is bellow :
$source = "http://programin.wordpress.com/";
$file = fopen("$source", "r") or exit("Unable to open file!");
while(!feof($file))
{
$line = fgets($file);
if($pos1 = strpos($line , "h2" )) //for catching the blog post titles
{
echo $line;
}
else if($pos2 = strpos($line,"meta")) //for catching the dates and categories
{
echo $line;
}
}
fclose($file);
?>
I have used css for attractive output. Code of css is bellow :
html,body{margin:0.5%;padding:0}
div#header h1{
height:80px;margin:0;
border-bottom:2px solid #00529B;
border-top:2px solid #00529B;
border-left:2px solid #00529B;
border-right:2px solid #00529B;
background: #BDE5F8;
padding-left:5px;
font-family :'Trebuchet MS';
color : #00529B;
}
h2{ font-family :'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 15pt;
color: green;
text-align: left;
margin-top: 0.5%;
}
div#container{
border-bottom:2px solid #00529B;
border-top:2px solid #00529B;
border-left:2px solid #00529B;
border-right:2px solid #00529B;
padding:4px 6px;
width:800px;
margin:0 auto
}
div#content{padding-left:5px; margin-top:3%}
.meta {
border-bottom: 1px dotted #00529B;
font-family:Arial, Helvetica, sans-serif;
font-size:11px;
color:black;
padding:4px 6px;
margin:0 0 10px 0;
}
a:link {color: #00529B}
a:visited {color:gray}
a:hover {color:green;font-size: 100%}
a:active {color:black}
a {text-decoration: none}
span.small {
color : green;
font-size:15px;
}
Simple Time Machine in PHP
I am learning php. I have made one php program which is about the time machine. This is very simple program using mktime() and date() functions. For that you should make first html form page for accepting the name of user and number for to go further days (i.e. Future). The code is given below,
<form action = "welcome.php" method = "POST"> <table> <tr><td> Enter Name:</td><td><input type = "text" name = "name"> </td></tr> <br /> <tr><td> Enter Number:</td><td> <input type = "text" name = "num"> </td></tr> <br / > <tr><td> <input type = "submit"> </td><tr> </table> </form>
After that you should make another page for PHP code. The code is given below,
<?php
$name = $_POST['name'];
$num = $_POST['num'];
echo "Welcome <b> ".$name;
echo "</b> <br><br><hr>";
for($i=1;$i<=$num;$i++)
{
$tomorrow = mktime(0,0,0,date("m"),date("d")+$i,date("Y"));
if($i==$num)
{ echo "<br><hr><b>";
echo " Welcome to the future !!! ".date("m-d-Y",$tomorrow);
echo "</b> <br>";
echo $name.", You are in future... ";
}
else
{
echo date("m-d-Y",$tomorrow)." You was going through this date to the future<br>";
}
}
?>
Start the apache server or your any php supported server and run these program on server.
And Enjoy The Time Machine..
Deep study in php
I had php and java in my t.y.bsc’s syllabus. I also had project in t.y.bsc’s syllabus. Because of project i had given the concentration on my project. My project was in java so i studied java more than php. Now i am thinking on new project in php. For that i will study hard in php. From my knowledge php is more fundoo and interesting than java. I like php because it has more fundoo functions. I like the concept of associative array.



