Wednesday, January 19, 2011

PHP Pagination

Ever use a Search Engine? I'm sure you have, lots of time. When Search Engines found thousands of results for a keyword do they spit out all the result in one page? Nope, they use paging to show the result little by little.
Paging means showing your query result in multiple pages instead of just put them all in one long page. Imagine waiting for five minutes just to load a search page that shows 1000 result. By splitting the result in multiple pages you can save download time plus you don't have much scrolling to do.
To show the result of a query in several pages first you need to know how many rows you have and how many rows per page you want to show. For example if I have 295 rows and I show 30 rows per page that mean I'll have ten pages (rounded up).

Monday, November 1, 2010

Implementing AJAX

In the last post, we have learnt that what is AJAX.
Now in this post, we will implement it using PHP.
 The only important thing at the moment is that AJAX uses JavaScript so it needs to be enabled in your browser to successfully implement it.
To demonstrate the AJAX PHP connection we will create a very simple form with 2 input fields.
In the first field you can type any text and we will send this text to our PHP script which will convert it to uppercase and sends it back to us. At the end we will put the result into the second input field.
Let us see some simple html code:
<html>
<head><title>Ajax - PHP example</title>
</head>
<body>
<form name="testForm">
 Input text: <input type="text"  onkeyup="doWork();" name="inputText" id="inputText" />
 Output text: <input type="text" name="outputText" id="outputText" />
 </form>
</body>
</html>

Tuesday, October 26, 2010

Introduction to AJAX

·         Hmm... very interesting topic now i.e. AJAX.

·         First of all, what is AJAX????

·         AJAX = Asynchronous JavaScript and XML.

·         AJAX is a technique for creating fast and dynamic web pages.

·         It is a group of interrelated web development techniques used on the client-side to create interactive web applications.

·         With Ajax, web applications can retrieve data from the server asynchronously in the background without interfering with the display and behavior of the existing pageAJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

·         Data is usually retrieved using the XMLHttpRequest object.

·         Like DHTML and LAMP, Ajax is not a technology in itself, but a group of technologies.

·         Classic web pages, (which do not use AJAX) must reload the entire page if the content should change.

·         Examples of applications using AJAX: Google Maps, Gmail, Youtube, and Facebook tabs.

Wednesday, September 8, 2010

PHP Mail

• PHP Mail Introduction: One of the major uses of a server side scripting language is to provide a way of sending e-mail from the server and, in particular, to take form input and output it to an e-mail address. The mail() function allows you to send emails directly from a script.

• Requirements: For the mail functions to be available, PHP requires an installed and working email system i.e SMTP server that PHP can connect to.

Knowing SMTP server: SMTP is the acronym for Simple Mail Transfer Protocol, and an SMTP server is the machine that runs this protocol and sends out the mail. Running the protocol essentially means running a program such as Sendmail or Qmail if you're on a non-Windows machine. On Windows, the SMTP Service that is part of the Windows NT Service Pack or built in to the Windows 2000 operating system is typically the one running.

• "How can a server be available if it's not currently being run?" you might ask. Well, if that machine is connected to the Internet via a dial-up connection (or DSL or cable), you can use your ISP's outgoing mail server. For example, if your development machine is a Windows 98 box with a 56Kbps modem connected to the Internet via EarthLink, then you can use mail.earthlink.net as your SMTP server. Whatever e-mail client you use (Eudora, Outlook, Netscape Mail, and so on) as your outgoing mail server will also function within your PHP code as your SMTP server. The trick is making PHP aware of this little fact.

• The program to be used is defined by the configuration settings in the php.ini file.

Installation: The mail functions are part of the PHP core. There is no installation needed to use these functions.

• Runtime Configuration: The behavior of the mail functions is affected by settings in the php.ini file. In the php.ini master configuration file located in wamp icon, there are a few directives that need to be set up so that the mail() function works properly.

The options you want to check are:

• SMTP

• sendmail_from

• sendmail_path

Saturday, August 21, 2010