Sunday, April 17, 2011

Get the Mysql records in Xml format

Introduction
.................................................................................
This tutorial will show you how to take data that is stored in your mySQL database and easily turn it into XML.

$query ="select* from userdetails";
$resultID = mysql_query($query) or die(mysql_error());


$num = mysql_num_rows($resultID) ;
 if ($num != 0) {

 $file= fopen("xml/results.xml","w");

 $_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";

 $_xml .="<userdetails>\r\n";


while ($row = mysql_fetch_array($resultID)) {


$_xml .="\t<user>\r\n";
$_xml .="\t" . $row["userid"] . "\r\n";

$_xml .="\t\t" . $row["username"] . "\r\n";
$_xml .="\t</user>
\r\n";

}

$_xml .="</userdetails>
";

fwrite($file, $_xml);

fclose($file);

//echo "XML has been written";


} else {

echo "No Records found";

}


?>

Monday, April 4, 2011

Dynamic Site Map using PHP

the sitemap generate based on the directory structure of the site. You can easily exclude files and(or) directories.

The site map is an expandable list, similar to Windows Explorer and is accessible with or without JavaScript enabled on the user's browser. If JavaScript is not enabled, the list is simply displayed in its expanded format so all hyperlinks are visible. Directories and files are sorted alphabetical order . Note that the site map is generated from the file system, not the links contained in the pages.

this script functions by recursively calling itself to traverse the directory tree brgining at the site's root directory. It gets the file title from each file on the site and displays the page title, with a link to the file. Note that the script obtains the title of the page by extracting the text between the opening and closing title tags. That means that it only works on pages that exist (not all the variations that can be generated) and where the title is static and contained in the page.

Demo

Tuesday, March 29, 2011

Lightbox JS v2.05

Lightbox v2.0 uses the Prototype Framework and Scriptaculous Effects Library. You will need to include these three Javascript files in your header.





Include the Lightbox CSS file (or append your active stylesheet with the Lightbox styles).



Check the CSS and make sure the referenced prevlabel.gif and nextlabel.gif files are in the right location. Also, make sure the loading.gif and closelabel.gif files as referenced near the top of the lightbox.js file are in the right location.

Part 2 - Activate

Add a rel="lightbox" attribute to any link tag to activate the lightbox. For example:

image #1

Optional: Use the title attribute if you want to show a caption.
If you have a set of related images that you would like to group, follow step one but additionally include a group name between square brackets in the rel attribute. For example:

image #1
image #2
image #3

No limits to the number of image sets per page or how many images are allowed in each set. Go nuts!
demo