Adding items to a shopping cart in common e-commerce applications isn't very close to the actual "add to cart" metaphor, since it requires clicking an "add to cart" button, watch a new page (the shopping cart), and then go back to the shop or checkout with buttons.
Ajax allows to get closer to the cart metaphor, by enabling drag-and-drop interactions and giving immediate visual feedback, without leaving the shop.
Check this cool video and learn how to make your own Drag-n-Drop script using PHP Framework, Symfony Project.
Drag and Drop Tutorial (with a cool video)
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts
How to Create a Postgres and MySql Driver!!!!
The software that I write is not intended for just one customer who is locked into a single RDBMS. Instead it can be used by virtually any customer using the RDBMS of their choice. How is this possible? I deliberately designed and built my infrastructure around the 3 Tier Architecture which breaks down application code into three distinct areas of responsibility:
1. Presentation logic = User Interface, displaying data to the user, accepting input from the user.
2. Business logic = Business Rules, handles data validation and task-specific behaviour.
3. Data Access logic = Database Communication, constructing SQL queries and executing them via the relevant API.
It is only the Data Access layer which communicates with the database, therefore it should be possible to communicate with another database simply by changing the component which exists within this layer. I have already produced two versions of my Data Access Object for MySQL:
One for versions up to 4.0 which uses the original mysql_* functions.
Another for version 4.1 and above which uses the 'improved' mysqli_* functions.
The purpose of this article is to document my experiences while producing a DAO for a totally different RDBMS, in this case for PostgreSQL (version 8.0.3).
[source]
1. Presentation logic = User Interface, displaying data to the user, accepting input from the user.
2. Business logic = Business Rules, handles data validation and task-specific behaviour.
3. Data Access logic = Database Communication, constructing SQL queries and executing them via the relevant API.
It is only the Data Access layer which communicates with the database, therefore it should be possible to communicate with another database simply by changing the component which exists within this layer. I have already produced two versions of my Data Access Object for MySQL:
One for versions up to 4.0 which uses the original mysql_* functions.
Another for version 4.1 and above which uses the 'improved' mysqli_* functions.
The purpose of this article is to document my experiences while producing a DAO for a totally different RDBMS, in this case for PostgreSQL (version 8.0.3).
[source]
How to Handle MySQL Data Handling Through PHP!!!!!
Most interactive websites nowadays require data to be presented dynamically and interactively based on input from the user. For example, a customer may need to log into a retail website to check his purchasing history. In this instance, the website would have stored two types of data in order for the customer to perform the check – the customer’s personal login details; and the customer’s purchased items. This data can be stored in two types of storage – flat files or databases
Flat files are only feasible in very low to low volume websites as flat files have 3 inherent weaknesses:
1. The inability to index the data. This makes it necessary to potentially read ALL the data sequentially. This is a major problem if there are a lot of records in the flat file because the time required to read the flat file is proportionate to the number of records in the flat file.
2. The inability to efficiently control access by users to the data
3. The inefficient storage of the data. In most cases, the data would not be encrypted or compressed as this would exacerbate the problem no. 1 above
Continue Reading The Tutorial
Flat files are only feasible in very low to low volume websites as flat files have 3 inherent weaknesses:
1. The inability to index the data. This makes it necessary to potentially read ALL the data sequentially. This is a major problem if there are a lot of records in the flat file because the time required to read the flat file is proportionate to the number of records in the flat file.
2. The inability to efficiently control access by users to the data
3. The inefficient storage of the data. In most cases, the data would not be encrypted or compressed as this would exacerbate the problem no. 1 above
Continue Reading The Tutorial
How to Install PHP on Windows!!!!
A brochure-style Web site may be sufficient for a business that simply wants a basic Web presence — some static pages to inform the visitor of the company's off-line contact information. But most organizations want a Web site that can interact with the visitor, delivering custom content in dynamically-generated pages, and storing visitor information in a database. Such a Web site requires several technologies: a Web server, a database system, and a scripting language for creating the Web pages. Currently the most popular choices are Apache, MySQL, and PHP, respectively.
Your PC can be turned into a fully capable Web development environment, by installing those three technologies, and configuring them so they communicate with one another. Admittedly, you can simply install and use PHP for its command-line processing. But for creating and testing dynamically generated Web pages on your local machine, then Apache needs to be already installed and working.
Continue Reading The Tutorial
Your PC can be turned into a fully capable Web development environment, by installing those three technologies, and configuring them so they communicate with one another. Admittedly, you can simply install and use PHP for its command-line processing. But for creating and testing dynamically generated Web pages on your local machine, then Apache needs to be already installed and working.
Continue Reading The Tutorial
About CodeIgniter: A Powerful PHP Framework
CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.

Its on the likes of CakePHP and other PHP based frameworks which work on MVC concepts.
Details of the Project:
Name: CodeIgniter
URL: http://codeigniter.com/
License: Free
Go check out the library.

Its on the likes of CakePHP and other PHP based frameworks which work on MVC concepts.
Details of the Project:
Name: CodeIgniter
URL: http://codeigniter.com/
License: Free
Go check out the library.
PHP Forms tutorials for Begineers!!!
It is time to apply the knowledge you have obtained thus far and put it to real use. A very common application of PHP is to have an HTML form gather information from a website's visitor and then use PHP to do process that information. In this lesson we will simulate a small business's website that is implementing a very simple order form.
Imagine we are an art supply store that sells brushes, paint, and erasers. To gather order information from our prospective customers we will have to make a page with an HTML form to gather the customer's order.
Note: This is an oversimplified example to educate you how to use PHP to process HTML form information. This example is not intended nor advised to be used on a real business website.
If you need a refresher on how to properly make an HTML form, check out the HTML Form Lesson before continuing on.
We first create an HTML form that will let our customer choose what they would like to purchase. This file should be saved as "order.html"
Continue Reading the Tutorial Here
Imagine we are an art supply store that sells brushes, paint, and erasers. To gather order information from our prospective customers we will have to make a page with an HTML form to gather the customer's order.
Note: This is an oversimplified example to educate you how to use PHP to process HTML form information. This example is not intended nor advised to be used on a real business website.
If you need a refresher on how to properly make an HTML form, check out the HTML Form Lesson before continuing on.
We first create an HTML form that will let our customer choose what they would like to purchase. This file should be saved as "order.html"
Continue Reading the Tutorial Here
PHP Sessions Tutorial for Begineers!!!
As a website becomes more sophisticated, so must the code that backs it. When you get to a stage where your website need to pass along user data from one page to another, it might be time to start thinking about using PHP sessions.
A normal HTML website will not pass data from one page to another. In other words, all information is forgotten when a new page is loaded. This makes it quite a problem for tasks like a shopping cart, which requires data(the user's selected product) to be remembered from one page to the next
A PHP session solves this problem by allowing you to store user information on the server for later use (i.e. username, shopping cart items, etc). However, this session information is temporary and is usually deleted very quickly after the user has left the website that uses sessions.
It is important to ponder if the sessions' temporary storage is applicable to your website. If you require a more permanent storage you will need to find another solution, like a MySQL database.
Sessions work by creating a unique identification(UID) number for each visitor and storing variables based on this ID. This helps to prevent two users' data from getting confused with one another when visiting the same webpage.
Note:If you are not experienced with session programming it is not recommended that you use sessions on a website that requires high-security, as there are security holes that take some advanced techniques to plug.
Read the complete tutorial Here
A normal HTML website will not pass data from one page to another. In other words, all information is forgotten when a new page is loaded. This makes it quite a problem for tasks like a shopping cart, which requires data(the user's selected product) to be remembered from one page to the next
A PHP session solves this problem by allowing you to store user information on the server for later use (i.e. username, shopping cart items, etc). However, this session information is temporary and is usually deleted very quickly after the user has left the website that uses sessions.
It is important to ponder if the sessions' temporary storage is applicable to your website. If you require a more permanent storage you will need to find another solution, like a MySQL database.
Sessions work by creating a unique identification(UID) number for each visitor and storing variables based on this ID. This helps to prevent two users' data from getting confused with one another when visiting the same webpage.
Note:If you are not experienced with session programming it is not recommended that you use sessions on a website that requires high-security, as there are security holes that take some advanced techniques to plug.
Read the complete tutorial Here
Some of the Best PHP FrameWorks!!!!
These are some of the most known and well respected frameworks for PHP.
1. Symfony Project
2. CakePHP
3. CodeIgniter
4. Zend Framework
5. PHP on Trax
6. Agavi
Do u know more? Drop in comments and I shall update the list here.
1. Symfony Project
2. CakePHP
3. CodeIgniter
4. Zend Framework
5. PHP on Trax
6. Agavi
Do u know more? Drop in comments and I shall update the list here.
How to use Scriptaculous Effects in a better way?

How to use Scriptaculous Effects in a better way?
Here is a simple snapshot from the demo page from 24ways.
Gather around kids, because this year, much like in that James Bond movie with Denise Richards, Christmas is coming early… in the shape of scrumptuous smooth javascript driven effects at your every whim.
Now what I’m going to do, is take things down a notch. Which is to say, you don’t need to know much beyond how to open a text file and edit it to follow this article. Personally, I for instance can’t code to save my life.
Well, strictly speaking, that’s not entirely true. If my life was on the line, and the code needed was really simple and I wasn’t under any time constraints, then yeah maybe I could hack my way out of it But my point is this: I’m not a programmer in the traditional sense of the word. In fact, what I do best, is scrounge code off of other people, take it apart and then put it back together with duct tape, chewing gum and dumb blind luck.
No, don’t run! That happens to be a good thing in this case. You see, we’re going to be implementing some really snazzy effects (which are considerably more relevant than most people are willing to admit) on your site, and we’re going to do it with the aid of Thomas Fuchs’ amazing Script.aculo.us library. And it will be like stealing candy from a child.
Check out the code and Demo on this page Here
If you like this tutorial, drop in comments.
How to get last inserted record ID in mysql?
How to get last inserted record ID in mysql?
mysql_insert_id function is used to "Get the ID generated from the previous INSERT operation"
How to use the function?
Example code:
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');
mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
?>
mysql_insert_id function is used to "Get the ID generated from the previous INSERT operation"
How to use the function?
Example code:
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');
mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
?>
Classes and Functions in PHP: Simple Tutorial for everyone
Classes and Functions in PHP: Simple Tutorial for everyone
A class is a function of PHP that has its roots in object oriented programming. The ability to use classes in PHP has been increasing with later versions. If you want to add the power of classes to your PHP programming, keep reading.
Introduction
Continuing our PHP functions article, we move on to creating classes. Let me say right at the start that you can write perfectly effective and useful PHP code without creating classes or going into object oriented programming. Another thing is that PHP, at its core, is not an object oriented language. This is because PHP was built from the C language, which is at its core a procedural language, rather than a methodical one. However, object oriented programming can be very powerful and PHP programmers are increasingly taking advantage of these capabilities, which have been greatly expanded since PHP4.
What is a class?
A class is a collection of variables and functions that serves a common purpose. It gives you the ability to think about real world objects and translate them into code. For example, let's try to describe a car. The class "car" might have variables: $name_of_car, $wheels, $steeringwheel, $windscreen, $lights, $pedals and $brakes. The functions of a car might include Turnleft(),Turnright() and Accelerate(). The function "Accelerate()" might take arguments such as $increase_speed. Now, all of the above describes a car and what a car does in both real terms and in code.
Now you might ask, couldn't this be done with regular functions and variables? Yes, it could, especially if you were talking about one car. But if you are talking about more than one car, then it would be impossible to keep up with all the various variables and functions associated with multiple cars. This is where classes become very useful, because classes bring all those variables and functions under one name. In this case, it's an object named "car." Now if you have more than one car, all you have to do is instantiate that object. The term instantiate basically means making a copy of the object. The new copy will have all the variables and functions of the original object available to it. You can include the class in any script that you create; the class will work the same.
Let me sound a cautionary note. Although OOP makes coding easier and more portable, the objects' execution time is less efficient than writing straight code. And while OOP speeds up project development drastically, more often than not, it produces less customized and slower applications. So, be aware of these pitfalls when choosing to use OOP.
OOP is arguably difficult to learn, so in this article I am going to use very simple examples to demonstrate how to use OOP. This should help new users grasp the concepts easily. Also, because OOP is such a huge topic I will only deal with the basics so as to give you the ability to easily learn the more advanced aspects of it.
For more read on here
http://www.devshed.com/c/a/PHP/Classes-as-PHP-Functions/
Cheerz
Web Coder
A class is a function of PHP that has its roots in object oriented programming. The ability to use classes in PHP has been increasing with later versions. If you want to add the power of classes to your PHP programming, keep reading.
Introduction
Continuing our PHP functions article, we move on to creating classes. Let me say right at the start that you can write perfectly effective and useful PHP code without creating classes or going into object oriented programming. Another thing is that PHP, at its core, is not an object oriented language. This is because PHP was built from the C language, which is at its core a procedural language, rather than a methodical one. However, object oriented programming can be very powerful and PHP programmers are increasingly taking advantage of these capabilities, which have been greatly expanded since PHP4.
What is a class?
A class is a collection of variables and functions that serves a common purpose. It gives you the ability to think about real world objects and translate them into code. For example, let's try to describe a car. The class "car" might have variables: $name_of_car, $wheels, $steeringwheel, $windscreen, $lights, $pedals and $brakes. The functions of a car might include Turnleft(),Turnright() and Accelerate(). The function "Accelerate()" might take arguments such as $increase_speed. Now, all of the above describes a car and what a car does in both real terms and in code.
Now you might ask, couldn't this be done with regular functions and variables? Yes, it could, especially if you were talking about one car. But if you are talking about more than one car, then it would be impossible to keep up with all the various variables and functions associated with multiple cars. This is where classes become very useful, because classes bring all those variables and functions under one name. In this case, it's an object named "car." Now if you have more than one car, all you have to do is instantiate that object. The term instantiate basically means making a copy of the object. The new copy will have all the variables and functions of the original object available to it. You can include the class in any script that you create; the class will work the same.
Let me sound a cautionary note. Although OOP makes coding easier and more portable, the objects' execution time is less efficient than writing straight code. And while OOP speeds up project development drastically, more often than not, it produces less customized and slower applications. So, be aware of these pitfalls when choosing to use OOP.
OOP is arguably difficult to learn, so in this article I am going to use very simple examples to demonstrate how to use OOP. This should help new users grasp the concepts easily. Also, because OOP is such a huge topic I will only deal with the basics so as to give you the ability to easily learn the more advanced aspects of it.
For more read on here
http://www.devshed.com/c/a/PHP/Classes-as-PHP-Functions/
Cheerz
Web Coder
How-To: Upload a File in PHP?
How-To: Upload a File in PHP?
Introduction
Lately I have seen a ton of questions on the message board about uploading files to the server. It seems as if this is an epidemic that needs to be cured. I have written a PHP class for file uploads which some members of the message board have used and it helped to simplify their lives. Today we will attempt to write our own highly customizable file upload class. Before we get started get yourself a soda and something to munch on because this might take a while. Ready....(pause for the gathering of goodies)..okay let's begin.
What is a class and why do I need one?
Well to put it simply a class is a series of functions that work hand and hand to create an outcome. The reason a class works so great with uploading files is because there are a ton of functions one could write that would all depend on each other's outcome before the final result can be determined. For this reason we write a class instead of 10 functions and taking the time to validate each one.
Another beauty of a class is you can call any of the features within the class that you wish. For instance, with this class there will be 'x' amount of functions, all playing their role in the outcome of the actual upload process. If you wish to use this class to only verify a file's size and not upload it to the server, well you can. If you just wanted to get the file's extension and validate it, you could. That is the beauty of a class. If set up properly, classes are artwork, not just heavy amounts of code.
For rest of the tutorial read here.
http://www.phpfreaks.com/tutorials/85/0.php
--Srinix
Introduction
Lately I have seen a ton of questions on the message board about uploading files to the server. It seems as if this is an epidemic that needs to be cured. I have written a PHP class for file uploads which some members of the message board have used and it helped to simplify their lives. Today we will attempt to write our own highly customizable file upload class. Before we get started get yourself a soda and something to munch on because this might take a while. Ready....(pause for the gathering of goodies)..okay let's begin.
What is a class and why do I need one?
Well to put it simply a class is a series of functions that work hand and hand to create an outcome. The reason a class works so great with uploading files is because there are a ton of functions one could write that would all depend on each other's outcome before the final result can be determined. For this reason we write a class instead of 10 functions and taking the time to validate each one.
Another beauty of a class is you can call any of the features within the class that you wish. For instance, with this class there will be 'x' amount of functions, all playing their role in the outcome of the actual upload process. If you wish to use this class to only verify a file's size and not upload it to the server, well you can. If you just wanted to get the file's extension and validate it, you could. That is the beauty of a class. If set up properly, classes are artwork, not just heavy amounts of code.
For rest of the tutorial read here.
http://www.phpfreaks.com/tutorials/85/0.php
--Srinix
Subscribe to:
Posts (Atom)