Posted by: Anil Kumar Panigrahi in: ● July 2, 2010
Hi friends,
In this post i want to explain how to create rss feeds using php code and get the data from mysql table.
1) Connect to database:
We already discussed about how to connect database using php code.See the following code to connect database:
1
2
3
4
5
6
7
8
9
10
11
<?php
DEFINE (’DB_USER’, ‘root’);
DEFINE (’DB_PASSWORD’, ‘root’);
DEFINE (’DB_HOST’, ‘localhost’);
DEFINE (’DB_NAME’, ‘rss’);
// Make the connnection and then [...]
Posted by: Anil Kumar Panigrahi in: ● June 3, 2010
In this post explains how to create thumbnail image using php code.
function make_thumb($img_name,$filename,$new_w,$new_h)
{
//get image extension.
$ext=getExtension($img_name);
//creates the new image using the appropriate function from gd library
if(!strcmp(“jpg”,$ext) || !strcmp(“JPG”,$ext) || !strcmp(“jpeg”,$ext) || !strcmp(“JPEG”,$ext))
$src_img=imagecreatefromjpeg($img_name);
if(!strcmp(“gif”,$ext) || !strcmp(“GIF”,$ext))
$src_img=imagecreatefromgif($img_name);
if(!strcmp(“png”,$ext) || !strcmp(“PNG”,$ext))
$src_img=imagecreatefrompng($img_name);
//gets the dimmensions of the image
$old_x=imagesx($src_img);
$old_y=imagesy($src_img);
$ratio1=$old_x/$new_w;
$ratio2=$old_y/$new_h;
if($ratio1>$ratio2) {
$thumb_w=$new_w;
$thumb_h=$old_y/$ratio1;
}
else {
$thumb_h=$new_h;
$thumb_w=$old_x/$ratio2;
}
// we create a new image with the new dimmensions
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
// resize the big image [...]
Posted by: Anil Kumar Panigrahi in: ● March 22, 2010
Hi, In php there is one predefined variable called $_SERVER, with that only we can get the complete information about server.
Once check the below script:
<?php
echo “<table border = ‘2′ style=’color:#ffffff’>”;
$i = 0;
foreach($_SERVER as $key=>$value){
if($i%2 == 0) {
echo “<tr bgcolor=’#993300′>”;
} else {
echo “<tr bgcolor=’#0099FF’>”;
}
echo “<td>”;
echo $key;
echo “</td>”;
echo “<td>”;
echo $value;
echo “</td>”;
echo “</tr>”;
$i++;
}
echo “</table>”;
?>
Posted by: Anil Kumar Panigrahi in: ● March 18, 2010
Hi friends,
In our php application some times we want to highlight the source code to user friendly , so the following function helped you to highlight the source code.
<?php
if (!empty($_POST[’text’])){
echo ‘<div style="border: solid 1px red; width:300px;height: 150px; padding: 20px; margin: 20px">’;
highlight_string(stripslashes($_POST[’text’]));
echo ‘</div>’;
}
?>
<form action="<?php echo $_SERVER[’PHP_SELF’]?>" method="post">
<textarea name="text" style="width: 300px; height: 150px;padding: 20px; margin: 20px"><?php echo [...]
Comments