Monday, March 29, 2010

Ajax autocomplete using PHP & MySQL

Today I have decided to implement an Ajax (jQuery) auto complete feature in PHP & MySql. jQuery makes remote scripting a piece of cake and that led me to spend more time coding additional functionalities for the auto-complete field. In this post i'll explain how to use my autocomplete field and in a following post i will explain all the code. So lets start!

Before continuing lets see My Demo to how it will work.


Besides the auto-complete code we need the jQuery library along with its Dimensions plug-in (all files are included in the zip files). Let’s include in the head of your page:


Now we need to call the function that will bring data to our auto-complete field - setAutoComplete.
The call to setAutoComplete is inside a jQuery special code that is only executed when the DOM is ready, or in other words, when all the code is already loaded. The setAutoComplete function takes 3 parameters:
  • the id of the input field
  • the id of the div that will hold the returned data
  • the URL of the remote script that will process the request
Be aware that the URL should reflect your remote script and that it will be combined with the text typed in the input field.
Now we include our stylesheet to define the look of the elements. We  need to define the styles of the div that will contain the results,  they include two classes for the selected and unselected items. Take a  look at the CSS file linked at the end of this post. There is also a  style for the input field.
To finish the client side part now we need to define the code of the input field as follows:
Now that the client side is finished it’s time for  the server script. Here is an example of a script that try to match  colors. I’m using PHP but you can use whatever language you prefer for  the job, of course. You just need to return the results as an array  encoded as JSON.
$link = mysql_connect('localhost', 'dbUsername', 'dbPassword');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db("database")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$result = mysql_query("SELECT name FROM  sks_color");
while ($row = mysql_fetch_assoc($result)) {
$colors[]=$row['name'];
}
mysql_free_result($result);
mysql_close($link);        // check the parameter
if(isset($_GET['part']) and $_GET['part'] != '')
{
// initialize the results array
$results = array();        // search colors
foreach($colors as $color)
{
// if it starts with 'part' add to results
if( strpos($color, $_GET['part']) === 0 ){
$results[] = $color;
}
}         // return the array as json with PHP 5.2
echo json_encode($results);
}
Now every things done! As said before, we return the data as an array encoded as JSON. If you are running PHP >= 5.2.0 or the json extension you simply use json_encode for the job.

Courtesy:  Sujit Kumar Shah

Saturday, March 20, 2010

Step by step guide to install component in Joomla

Step By Step Installation of Joomla 1.5 component

Hello World

Introduction:

A "hello world" program is a classic software program that prints "Hello world!" on a display device. It's very popular introductory tutorial for teaching a programming language or an application framework. Such a program is typically one of the simplest programs possible.
This Joomla 1.5 "hello world" component is not an exception. I will keep it as simple as possible. The main purpose of this component is to encourage joomla developers to implement joomla 1.5 components and my personal goal is to sort out my thoughts of "clean" component. Believe or not I' m also just a joomla developer learner.
If you have any comments please go to developers joomla1.5 forum My next tutorial will be "hello world" using the new MVC framework included in Joomla! 1.5, so keep in touch.

  1. Install joomla 1.5 beta 1
-my personal tip is to use xampplite http://www.apachefriends.org/en/xampp.html this package contains all we need to try joomla.
Pros :
    1. it doesn't install any rubbish
    2. we don't need to be afraid of getting interfere with our registry or services
    3. easy to install
    4. simple and portable (pack, copy, unpack, use; easy to change a directory path)


  1. Download component from website
  2. http://www.vojtechovsky.net/joomla/com_helloworld.zip

  1. Log in joomla as Administrator user
  2. Extensions->”Install/Uninstall”


joomla15 joomla component free


  1. Press “Browse” button and find you downloaded file com_helloworld.zip on your computer.

  1. Install component by pressing “Upload File & Install“button.

create joomla tutorial web site

  1. Test Administration module
  2. create new free joomla component




  1. Make menu for our new component
  2. download free component joomla
    free joomla tutorial complete guide
    Menus -> Main Menu -> New -HelloWorld(double click) ->Name: Show me HelloWORLD!

  1. Let's show me new component

Go to your joomla website and click on Show me HelloWORLD!link vojtechovsky joomla delphi tutorial



  1. What about component localization?
You will need to have installed czech language package. It's not finished in joomla 1.5 yet so let's cheat a little.
Copy “cs-CZ” folder from your joomla installation folder (e.g. c:\web\xampplite\htdocs\j15\installation\language\cs-CZ) to your language folder and your administrator language folder. (e.g. c:\web\xampplite\htdocs\j15\language\cs-CZ and c:\web\xampplite\htdocs\j15\administrator\language\cs-CZ )
If you didn't prepare it before the component instalation you have to uninstall/install the component.
Let's make some testing.

Go to Administrator section and select Czech language for both site/administrator as DEFAULT!

vojtechovsky create component joomla



Go to component administration/joomla site and see the component text in czech. component guide joomla15

joomla15 free component tutorial


  1. Check out the joomla system log file
[joomla folder ] + \logs\error.log
(e.g. c:\web\xampplite\htdocs\j15\logs\error.log )
#Version: 1.0
#Date: 2007-02-06 16:51:17
#Fields: date time level c-ip status comment
#Software: Joomla! 1.5.0 Beta [ Khepri ] 12-Oct-2006 00:00 GMT
2007-02-06 16:51:17 0 127.0.0.1 1 hellodefault :Hello World. I just finished my first Joomla 1.5 component.
2007-02-06 16:51:26 0 127.0.0.1 1 helloworld :Hello World
2007-02-06 16:51:29 0 127.0.0.1 1 helloagain :Hello Again
2007-02-07 17:03:18 0 127.0.0.1 1 helloagain :Hello Again
2007-02-07 17:03:20 0 127.0.0.1 1 helloworld :Hello World
2007-02-07 17:05:00 0 127.0.0.1 1 helloworld :Ahoj Světe
2007-02-07 17:05:03 0 127.0.0.1 1 helloagain :Ahoj Znova
2007-02-07 17:05:11 0 127.0.0.1 1 helloworld :Ahoj Světe
2007-02-08 16:55:54 0 127.0.0.1 1 helloworld :Hello World
2007-02-08 16:55:58 0 127.0.0.1 1 helloagain :Hello Again
2007-02-08 16:56:14 0 127.0.0.1 1 hellotestfoo :Ahoj Světe, moje první testovací funkce byla právě spuštěna.
courtesy: http://www.vojtechovsky.net/joomla/

Paypal Integration - step by step guide

Paypal Gateway Integration:
Step 1: Goto developer.paypal.com
Step 2: Signup for an account and I use the following information.
pass: trainingcenter
you have to confirm your email address by click the link in mail send by paypal.
Childhood best fr: karamba
Favorite Restaurent: piza
My primary payment solution: Website Payments Standard
Create
Step 3: Create Business Account (I use Preconfigured link)
Pass: 268724681
Country:
United States
Business Name:
None
Credit Card:
Visa   4109533352958088
Exp Date:  3/2015
Bank Account:
Checking (Confirmed)
Routing Number: 325272063
Bank Account Number: 634389161585402
Balance:
0.00 USD
Email:
Confirmed
Step 4: Create Personal Account (I use Preconfigured link)
Buyer acc: person_1268889297_per@gmail.com
Pass: 268889126
Country:
United States
Business Name:
Aminul islam’s Test Store
Credit Card:
None
Bank Account:
Checking (Confirmed)
Routing Number: 325272063
Bank Account Number: 870793346219927
Balance:
8888.00 USD (Max: 9999)
Email:
Confirmed
Step 5: Click API Credentials Link from left menu. API created automatically and you just need to use those. For me here are the info:
Test Account: jbltr1_1268724741_biz@gmail.com Created: Mar. 16, 2010 00:32:27 PDT
API Username: jbltr1_1268724741_biz_api1.gmail.com
Password: 1268724747
Signature: AFcWxV21C7fd0v3bYYYRCpSSRl31AF95j1hyudD2R8r7TVOp6tyt4smZ
Extract
Step 7: open PP_PHP_NVP_Samples/constants.php and set up API Credentials Line no: 23, 33, 39.
Step 8: Run http://localhost/PP_PHP_NVP_Samples and click “ExpressCheckout - Sale” Link
Enter your personal account details as:
Pass: 268889126
[Note: Make sure you are signed in at paypal.developer.com For me Login Info: jbl.training@gmail.com / trainingcenter]
Click “Buy” button
And finally http://localhost/PP_PHP_NVP_Samples/DoExpressCheckoutPayment.php page shows you Confirmation of your transaction
When come back from paypal (after successful transaction)it comes to
Here LastTakewayId is my variable added paypal/ReviewOrder.php page at $returnURL=urlencode($url.’/ReviewOrder.php?currencyCodeType=’.$currencyCodeType.’&paymentType=’.$paymentType.’&LastTakewayId=’.$_SESSION['LastTakewayId']);
TIPS:
1. Have a look Test Email from the left menu
2. Maximum time I login in an account at developer.paypal.com and use another account’s email and pass while transaction (during purchase)

Courtesy :
Md. Aminul Islam

Thursday, November 12, 2009

30+ Animated Tab-Based Interface and Accordion Scripts

if you really want to add features of nice and gorgeous looking ajax and tab support to your web application and websites then you can look at here http://dzineblog.com/2008/10/30-animated-tab-interface-and-accordion-scripts.html

it will help you to get your desired contents at one place

happy coding !

Monday, October 12, 2009

Usefull Links

top 100 ajax forms
http://www.noboxmedia.com/top-100-ajax-form-related-scripts-for-2007/

Dynamic add button,textbox
http://viralpatel.net/blogs/2009/01/dynamic-add-textbox-input-button-radio-element-html-javascript.html

21 collection of datepicker
http://www.bitrepository.com/a-collection-of-free-javascript-date-pickers.html

jquery datepicker
http://www.filamentgroup.com/lab/date_range_picker_using_jquery_ui_16_and_jquery_ui_css_framework/

dhtml goodies
http://www.dhtmlgoodies.com/packages/dhtml-suite-for-applications/demos/demo-pane-splitter.html

Upload files into MySQL using php | Internet Resources | Cpworld2000.com
http://www.cpworld2000.com/article/upload-files-into-mysql-using-php/

dhtmlxCalendar - DHTML JavaScript Calendar component
http://www.dhtmlx.com/docs/products/dhtmlxCalendar/

MooTools DatePicker Example
http://www.styledisplay.com/mootoolsdatepicker/

Tabs - jQuery plugin for accessible, unobtrusive tabs
http://stilbuero.de/jquery/tabs/#fragment-3

Wednesday, May 6, 2009

Easy AJAX inline text edit 2.0

a straight forward tutorial to describe how to us inline text edit using ajax without adding a submit button or edit button in your web apps.

how you can make it work (5 easy steps for integration)

  • Download this Javascript file: InstantEdit 2.0 JS
  • Create a update file that handles the input. For example this PHP: Update File
  • In your page add the javascript:
  • Set fixed vars (like hidden elements in a field post). These will be posted with the editable field so you can identify a user/session.
  • Last step: in your HTML for any editable field add a SPAN arround it:
    John Doe
    Note: id is the fieldname (?userName=John Doe&), and should be unique!

how it works

A small piece of javascript reads al SPAN tags, checks if it has class=“editText” and a id=. If that is true, it adds a onclick function. That onclick function will create a textfield or input (depending on the size of the editable text). Someone has the ability to edit the field. When the text field is blurred, it will read the contents, and starts a XMLHttpRequest and ‘sends’ the content + fieldname + any set vars to an update file. That file will update your database, and reply with the newly set text and the textfield will dissapear again.

IE? FF?

This script works in internet explorer, netscape and firefox. Any other platforms haven’t been tested. That’s kinda up to you.

Codeigniter a robust php framework

codeigniter is a php frramework based on MVC architecture that is model view and controller. let me describe in short about MVC issues here.-

CodeIgniter is based on the Model-View-Controller development pattern. MVC is a software approach that separates application logic from presentation. In practice, it permits your web pages to contain minimal scripting since the presentation is separate from the PHP scripting.
  • The Model represents your data structures. Typically your model classes will contain functions that help you retrieve, insert, and update information in your your database.
  • The View is the information that is being presented to a user. A View will normally be a web page, but in CodeIgniter, a view can also be a page fragment like a header or footer. It can also be an RSS page, or any other type of "page".
  • The Controller serves as an intermediary between the Model, the View, and any other resources needed to process the HTTP request and generate a web page.

CodeIgniter has a fairly loose approach to MVC since Models are not required. If you don't need the added separation, or find that maintaining models requires more complexity than you want, you can ignore them and build your application minimally using Controllers and Views. CodeIgniter also enables you to incorporate your own existing scripts, or even develop core libraries for the system, enabling you to work in a way that makes the most sense to you.

Followers