Archive | PHP

# Looking for Open Source Charting system? Here it is

After a bit of research and trying with different charting and reporting libraries in Java, C++ etc, I finally found a library which is not only powerful but extremely simple as well.

Open Flash Chart

I must tell you, I have started using it and it is damn good.

The best part being that it has so much of native support to PHP that anyone who loves coding in PHP should fall in love with this graphing library.

VIsit the above URL link and see some demos of how good it is

Did I tell u that it is totally free, even for commercial use? Simply Awesome. Go check it out.

Cheerz
Shri

If you are reading article, you might also be interested in the PHP and Scriptaculous Book I have authored.

The book gives you insights about effects, drag-n-drop, slideshows, applications, auto-completion, in-place editing and more. Complete code snippets and explanations.

CHECK out and BUY the PHP and Script.aculo.us  book {My Book} at Packt official site
http://www.packtpub.com/php-and-script-aculo-us-web-2-0-application-interface/book

# Learn how to play with Flash, Mysql & PHP

Its one of those cool tutorials I have ever come across. It helps us in understaning how to integrate and play with Flash, Mysql and PHP.

http://www.creativecow.net/articles/brimelow_lee/php_mysql/php_mysql_flash.html

Cheerz
SHri

If you are reading article, you might also be interested in the PHP and Scriptaculous Book I have authored.

The book gives you insights about effects, drag-n-drop, slideshows, applications, auto-completion, in-place editing and more. Complete code snippets and explanations.

CHECK out and BUY the PHP and Script.aculo.us book at Packt official site

PHP and Script.aculo.us Book

http://www.packtpub.com/php-and-script-aculo-us-web-2-0-application-interface/book

# Advanced Word Count for PHP!!!!!

If you have tried counting words in a string in PHP, you sure must have used “explode” function.

Its a pretty simple function and can be used in N-ways. A general simple function can be written as


$String = "This is my blog";$words = explode(" ",String);
$num = count($words);



Now, this should give you the number of words (4) and following with the count of number of words{This, is, my, blog}.

BUT, the real problem is if your string is “Hello     World”, the number of words here are 7 and count is also 7. How come? THats coz, of the fact the function explode takes delimiter as a space and will count the spaces, commas, etc also as words.

I have found a better way of doing the same. So here I am sharing with you.

Instead use this function, in which we check wheather the word is having any integer, charcter etc in it or not. If its a space we can royally ignore it


function wordCount($string){$words = "";
$string = eregi_replace(" +", " ",$string);
$array = explode(" ",$string);
for($i=0;$i < count($array);$i++)
{
if (eregi("[0-9A-Za-zÀ-ÖØ-öø-ÿ]", $array[$i]))
$words[$i] = $array[$i];

}
return $words; }  In this way, we can get the words as the user must have typed omitting the spaces and junk characters. This function will return you a array of words in the string, and further we can even make it only Words++ to count how many words are there. So this function can actually work for 2 purposes. 1. Count the number of Words in a string 2. Get the words in array Hope you find this useful. CHeerz Shri If you are reading article, you might also be interested in the PHP and Scriptaculous Book I have authored. The book gives you insights about effects, drag-n-drop, slideshows, applications, auto-completion, in-place editing and more. Complete code snippets and explanations. CHECK out and BUY the PHP and Script.aculo.us book at Packt official site http://www.packtpub.com/php-and-script-aculo-us-web-2-0-application-interface/book # Yahoo SDK & YUI are simply awesome!!!! I must appreciate the fact on how much Yahoo gives freedom and power to developers through libraries and toolkits. I am currently using YUI and Yahoo SDK for building a small application and I am highly impressed with the libraries. For sure Y! are doing great job, making our life lil more simpler I have been using some libraries like Rico, scriptaculous, Dojo and trust me when I say, YUI stands tall here. If you havent tried it yet, get yourself hooked on http://developer.yahoo.com. Loads of tutorials, code, demos. For FREE Try it now… Cheerz Shri If you are reading article, you might also be interested in the PHP and Scriptaculous Book I have authored. The book gives you insights about effects, drag-n-drop, slideshows, applications, auto-completion, in-place editing and more. Complete code snippets and explanations. CHECK out and BUY the PHP and Script.aculo.us book {My Book} at Packt official site http://www.packtpub.com/php-and-script-aculo-us-web-2-0-application-interface/book # Web Tip #1: Yellow Fade Technique (YFT) Web 2.0, Web 2.0 *Yawn Yawn* I guess the web is half full with Web 2.0 jagron. I wont go deep in explaning what exactly web 2.0 is, but I would stress on one point. “No Refreshing of Whole Page” {AJAX, as we call it} I surf web for more than 20 websites {new} a day, one thing I find pretty common and uncommon is the UI. Some sites suck so-much that I never visit them again, and some are so awesome that i fall in love with them. So here, I am starting a new section “Web Tips” for web workers to plan and design sites in a way to impress the users. Web Tips #1: Yellow Fade Technique When you are using AJAX in your site, often one feels it’s a big deal to implement AJAX and then they feel like next Google. But, most of them fail to understand that the user is unaware of what happened just now? For god sake, he doesnt understand AJAX So the user panics, can be to an extent, he says “Goodbye” What can be done to avoid such things? Tell the user you have posted/got the data. How? Simple Yellow Fade Technique Just change the background of the DIV to light yellow and then once the operation is done, again with a time duration fade it out to the original color. This really helps users in understanding that something has happened. If you are one of the fans of WordPress, it has that implementation in the comments tab. I am implementing it as well, so you can expect a YFT treat tutorial soon from me. If you are reading article, you might also be interested in the PHP and Scriptaculous Book I have authored. The book gives you insights about effects, drag-n-drop, slideshows, applications, auto-completion, in-place editing and more. Complete code snippets and explanations. CHECK out and BUY the PHP and Script.aculo.us book {My Book} at Packt official site http://www.packtpub.com/php-and-script-aculo-us-web-2-0-application-interface/book Cheerz Sridhar # Tutorial: How-To make a Tag Cloud using PHP & MySQL How to make Tag Cloud using PHP & MySQL Tag Clouds are pretty common now-a-days in almost all the web 2.0 company sites. Be it Technorati, Zoom CLouds, WordPress, Blogger etc. Why Tag Clouds are important? Pretty much for the same reasoon: Appealing Users. On seeing all these even I have decided to introduce the Tag Cloud feature in our project. Now, the very important question: How do we code to create a Tag Cloud using PHP & MySql? Here I will show you how to code it. First the logic: 1. Collect all the tags & Count{how-many times it has been tagged} from DB{MySQL} 2. Put them into a array {PHP} 3. Calculate the maximum and minimum count of the tags used 4. Now, loop through each tag and just change the size of the font. 5. Define a simple class say “wrapper” which will contain the tag clouds 6. Call the function to generate the tag cloud. {Javascript} Now, since Im falling short of time, so I will cut the crap and you guys take the code directly. Yes, a word from me, I will surely update it as time permits in full detail. Cheerz Srinix PS: Download the Code here: Tag Cloud Code If you are reading article, you might also be interested in the PHP and Scriptaculous Book I have authored. The book gives you insights about effects, drag-n-drop, slideshows, applications, auto-completion, in-place editing and more. Complete code snippets and explanations. PHP and Script.aculo.us Book CHECK out and BUY the PHP and Script.aculo.us book at Packt official site http://www.packtpub.com/php-and-script-aculo-us-web-2-0-application-interface/book # FPDF, PDFLib with PHP which one to choose? FPDF is a php class used to generate PDF files out of text or html files. ‘F’ stands for Free. Whereas PDFLib is also a powerful class for generating PDF files, but its not free. Have you tried any of these with PHP? Which one would you prefer? In terms of features, customization, encoding facilities and above all performance. Have you tried using ajax to get data from mysql and then post it to create PDF using PHP? This weekend, I am working on both of them, if you happen to work on them already. Please drop me a line. Cheerz Sridhar # Web tutorials *Yawn Yawn*: Webonic Do u also Yawn thinking of tutorials available on web? Be it Php, Mysql, CSS etc, Its all same stuff, again and again in new fonts!!!! Its time for some real new useful stuff and not same yawning. I have started a new blog, which I call it as my technology playground. Its important to write code, and Its even more important to build some useful code and share it with community. Since, this blog is more personal. I will write and collect all the tutorials which I will be working/learning for buliding my own web product. http://webonic.blogspot.com/ Webonic will contain tutorials, code, demos related to PHP, MySQL, AJAX & CSS. Its not user-generated/collected, all will be stuff I am working on. You are free to add if you want to. Happy Hacking Sridhar # Tutorial: How to make Script.aculo.us Based Slideshow Before you go on to read this article. If your a newbie to using Script.Aculo.us AJAX library, I would recommend my previous post on getting started with Script.Aculo.us. Read the article here Okay, so I presume that you have gone through the previous tutorial. In this tutorial we will see how to make a simple slideshow for our website. You can also download the script along with HTML file at the bottom of the tutorial. Slideshow’s are pretty common among webstites today. But, most of them being in Flash. Since we can add the same beauty using AJAX I thought of giving it a shot. So lets get started!!! Start Javascript functionality here!!! <script type=”text/javascript”> var slides = array(‘slide1′,’slide2′,’slide3′); // we define a array with all the div-Id’s of the slides. we have to define a variable “wait” so lets declare and assign some value to it. var wait = 500; // interval and time in milliseconds 1. We need the slideshow to start as soon as the site is launched. For that we have to define a javascript function. function start_slideshow() { setInterval(SlideShow(), wait); // This is a javascript function which acts as a timer. } Now, we need to define the actual functionality for the slideshow. function SlideShow() { Effect.Fade(Slides[i], { duration:1, from:1.0, to:0.0 }); i++; if (i == 3) i = 0; Effect.Appear(Slides[i], { duration:1, from:0.0, to:1.0 }); } 2. We have to add this to our html code. <body onload=”start_slideshow()”> 3. Lets add some slides to the page. <div id=”slideshow-content”> <div class=”slide1″ id=”slide1″> <h2>My First Slide</h2> <p> Add some content for your first slide. </p> </div> // First slide div ends here <div class=”slide2″ id=”slide2″ style=”display: none;”> <h2>My Second Slide</h2> <p> Add some content for your second slide. </p> </div> // Second slide div ends here </div> Imp Note: Note how we must use an outer DIV tag to use this. Its a must to have an outer DIV tag. Now, just put all the code in one place and you can see your slideshow working!!!! If you have tried/ have any suggestions to improve it pls drop in comments. Cheerz Shri PS: 1] Planning to write a tutorial on slideshows based on images with various control effects. 2] You can also download the code in attachments. Download the tutorial and see it working Download: slideshow.txt If you are reading article, you might also be interested in the PHP and Scriptaculous Book I have authored. The book gives you insights about effects, drag-n-drop, slideshows, applications, auto-completion, in-place editing and more. Complete code snippets and explanations. CHECK out and BUY the PHP and Script.aculo.us book at Packt official site PHP and Script.aculo.us Book # Now, after CamStudio. its Script.aculo.us + OpenIndx I was like busy for now 2 weeks, deciding which AJAX library to use with OpenIndx. I have tried enough of them now, which includes Dojo, OpenRico, YUI, Script.aculo.us. What features am I looking for in a Javascript AJAX library? These features are a must for OpenIndx: Drag-n-Drop Fade-In/Fade-out Flexible with PHP Inline Editors/Multi-Line editor/ Full-Fledge editor integration(TinyMCE/FCkeditor) Sliders After all these screening I have decided to go with script.aculo.us. After All its about UI, Honey!!! So if you are one who likes the AJAX-powered functionality in WordPress. I must tell you even wordpress is using Script.aculo.us Who else using Script.aculo.us? To name some of the key projects WordPress, Apple etc. So what does it mean anyway? Expect beautiful UI and powerful functionality. When will we see it? Did I tell you the release date is June 07. Yes, it would just be a alpha version with all basic features first. Based on your feedback we will be modifying and adding new features on requests. okay, so keep hanging around. Be good, Take care Cheerz Shri # Why we started OpenIndx? Google’s Mission “Google’s mission is to organize the world’s information and make it universally accessible and useful” Well, I sat thinking on this for a while. I found out, there is enough data around us available in all possible formats. Data is useless untill we are extracting the information out of it and represnt it properly. Hence, the idea is born, which we call it OpenIndx. We aim to provide set of suites which are easy, flexible, powerful and above all useful for users/ organizations/ Institutes to extract needed Information from data and represent in more effecient way, ofcourse for free. Data –>Information We aim to provide a powerful middleware, which will become something like this. Data –> OpenIndx –> Information I hope for those who were still wondering what purpose OpenIndx is going to server. This explanation would make it clear. Still have some query? Drop a mail …right away… Cheers Sridhar # Official Blog for project OpenIndx Finally, here we go live with the official blog for project OpenIndx!!! Today 21st Feb 2007, OpenIndx goes Live with official blog!!! OpenIndx Official blog : http://openindx.wordpress.com Project OpenIndx finally gets an official blog where all the stuff related to Developement, Technology, AJAX,Learnings, Fun, Team,just anything and everything about OpenIndx will be geared up!!! Do you have an extra edge to contribute? Do you wish to change the rules someone has set? You like challenging self?. Read further!!! Yup, OpenIndx is the project you should be working on. Just hang on pals. Spread the word. Let the project grow exponentially. Call for go MAD {Make a Difference}!!! Cheers src # Things I am learning about building a cool web site!!! Obviously, many of us visit more than 10 websites a day, atleast I do. But, then what makes a website look awesome while some seriously suck? While working on OpenIndx, I am learning couple of things which I am sure will make the difference between a wonderful site and a sucking one!!! 1. UI is the software: This is a universal rule for all web apps. Users will see what you are selling. If your site is one which takes Ruby On rails, AJAX, Perl, Python and above all looks like a porn one, trust me users will never visit your site again, ofcourse untill you really offer porn. I came across couple of sites which uses almost all the colors avialable in the color pallete. False assumption that mmore colors will make the site more impressive. Moral: Web apps UI should be appealing, decent, easy and above all dead friendly for a user to use it and make them comeback. Colors used should be eye-candy to make users fall in love with the site. Case Study: In OpenIndx we are trying to make the look, UI, feel simpler and effective. 2. Features should be rolled frequently: I started deciding a bunch of features to roll out for the beta version of OpenIndx. But, this book GettingReal,really helped me giving a nice inputs on how-to approach when it comes to features. I identified simple, must and new features for OpenIndx for the beta version and the rest features will be rolled out to make the users stick to the site and the application. 3. Take Feedbacks at every point Feedbacks/Positive Critics are really helpful, provided you take it in a positive way. I talk with many people and friends, mainly to identify the solution they expect to be, the way they want, what will appeal them in the app. Once, you identify the key points, analysis of the same has to be done. Because our goal ultimately will be to provide end user what they want, to solve their pain points. These are some of my learnings while working on OpenIndx. Will keep posting more as I learn more from the progress of the project. Meanwhile if you are student,developer Designer/DBA or just interested in joining the project. Please drop a line. We can form a great team together. Cheers Sridhar # How to use JPGraph with PHP and MySQL? Getting frustated with very less content{Docs,Blogs, tutorials etc} available on web on how to use JPGraph with PHP and MySQL. I then decided to work and post an article which will give a clear picture on how to utilize the same. Lets start with the basics, tool required and softwares a must to have: 1. PHP 2. MySQL 3. Web Server {WAMP, LAMP} 4. JPGraph {Most Imp since we are trying to hack it} Now, assuming that everything required is in place. Lets start hacking JPGraph!!! First thing that we should do is to place JPGraph in the web folder. i.e WWW. Once we are done with the same, we can just run a trial on our localhost. While hacking JPGraph, I learned that whosoever have Object Oriented background, they can hack in less than 10 mins. Yes, less than 10 mins. U ready? OKay…Go ahead. include “/some folder/jpgraph/src/jpgraph.php” Now, depending on the need, of what chart,graph or diagram you are trying. Include the respective header file also. I will teach u how to hack for Bar Graphs. include “/some folder/JPGraph/jpgraph_bar.php” Now, since we have included the required libraries. Lets get straight to create objects of the same. and then call the functions to add more features.$graph = new Graph(250,150,”auto”);  // Declaring the graph and its properties
$graph->SetScale(“textint”);$graph->img->SetMargin(50,30,50,50);  // set the margin to the graph
$graph->SetShadow(); // Show a shadow behind Now, we will declare a object of BarPlot class.$bplot = new BarPlot(“Here parameter will the data u want to represent can be sent through DB or direct array”);
$bplot->SetFillColor(“yellow”); // Fill the graph with yellow color$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD); // use these fonts$bplot->value->SetAngle(45); // at what angel you want the values to be shown
$bplot->value->SetColor(“black”,”navy”);$graph->Add($bplot); // add the bar graph to actual graph$graph->Stroke();

Simillarly, we can do for rest also for Pie Charts etc.
Before I conclude I will give some tips on how to use the JPGraph reference materials.

1. Open the folder:   /JPGraph\docs\ref
2. In these you can find reference to all the classes and their respective functions, which makes very ease to access and use directly.

I hope this article will be of use to you. If you still have any doubts or issues. Drop a comment or mail. I will glad to help you out.

Happy Hacking!!!!
Cheers
Sridhar

If you are reading article, you might also be interested in the PHP and Scriptaculous Book I have authored.

The book gives you insights about effects, drag-n-drop, slideshows, applications, auto-completion, in-place editing and more. Complete code snippets and explanations.

CHECK out and BUY the PHP and Script.aculo.us book at Packt official site

PHP and Script.aculo.us Book

http://www.packtpub.com/php-and-script-aculo-us-web-2-0-application-interface/book