mysql
Asif Khalyani asked:


Introduction

Frequent visitors of ajax enabled websites, like ajaxian, have all witnessed them already: ajax rating widgets. They are flashy, animated, you can use them to rate the content (usually without refreshing the page) and if you could, you’d present them to your parents and marry them. Compared to the classic rating system, as on IMDb, they incite people to click them, reducing the effective rating process to only one click.

In this tutorial, I want to show you how to create the JavaScript framework to display the animated rating widget and how to connect it to your server backend by using some of the most common Ajax frameworks out there. I clearly separate the page creation from the JavaScript functions and the rating backend, to allow the script to be as flexible as possible and to be easy integrable into your existing website.

This tutorial is not meant to present you with a finished script (even though you could simply copy&paste the end result into your website and make it work without any problems), but rather to explain the design and implementation process that would enable you to create your own widgets if you’d need to. Getting started with the HTML markup

What It Is

This is a rating bar script done with PHP and mySQL that allows users to rate things like can be done all web 2.0-like with no page refresh. It is a major improvement on the previous version because it is now unobtrusive, meaning that if Javascript is off it will still work (although the page will refresh). You can also set the number of rating units you want to use (i.e. 4 stars, 5 stars, or 10 stars) on a rater to rater basis (see samples below or read the docs). A few other changes were made as well  see the docs for details. Note that this script isnt tied to any specific system (such as WordPress), so you should be able to adapt it to your situation without too much trouble. What are you waiting for? Check the Ajax Rating demos.

It is most important that there are no line breaks in this code, as this will complicate the DOM tree unnecessarily. If you are uncertain about what I just said, please read the W3Schools HTML DOM Tutorial for further reference, since we are going to access the DOM directly from within our JavaScript.

As you can see, the div container is pretty easy to generate in the server-side scripting language, requiring most of the time only one line:

printf(”%s”, ratingId, rating);

The “continue” keyword in our JavaScript code, just like in most other programming languages, continues with the next iteration of the loop and prevents the execution of the rest of the code during that iteration. Read the rating value

Now that we have all the rating containers, we can start by reading the rating value written as text inside the div container. To read that value, we access the first child node of the div container, which is a TextNode, and access its nodeValue, which returns the text CDATA in case of text nodes. This is done by the following line:

var rating = ratings[i].firstChild.nodeValue;

There is no graceful way to recover from that error, so I simply decided to continue with the next rating container and prevent that error from happening within the server backend.

Now, we need to loop over the number of stars that are displayed and check what the image graphic will be that is displayed on the star. Using the HTML DOM function createElement(), we initialize a new image and progressively add the respective values to that element. Of course, the first thing we are interested in is the displayed image: we could either test the rating against the current iteration value or we could decrement the rating value during each iteration and test against 1, 0.5 and 0. I decided to decrement the rating during each iteration, which presents me with three simple cases to test: if the rating is greater than or equal than 1, the star is “on”, if the rating is exactly 0.5, the star is “half” otherwise, the star is “off”. This results in the following code:

for (var j = 0; j < NUMBER_OF_STARS; j++)

{

var star = document.createElement(’img’);

if (rating >= 1)

{

star.setAttribute(’src’, ‘./images/stars/rating_on.gif’);

rating–;

}

else if(rating == 0.5)

{

star.setAttribute(’src’, ‘./images/stars/rating_half.gif’);

rating = 0;

}

else

{

star.setAttribute(’src’, ‘./images/stars/rating_off.gif’);

}

ratings[i].appendChild(star);

}

Conclusion

Our current JavaScript allows us to transform specially marked div containers into animated rating widgets that we can use in specialized Ajax frameworks to link to our server backend. The HTML markup is completely separated from the JavaScript code, which will leave the user with a not very stylish but still visual display of the current rating in case JavaScript is disabled. I’ve put together a ZIP file with the current result, containing an HTML file, a CSS file, the JavaScript file and the images. Connect the widget to the server with different frameworks

Please make sure to delete the “window.onload=init_rating;” line in the “script.js” file if you downloaded the .zip file, since we’re using the specialized framework onload event.

The examples below are only an illustration of how this given task is achievable with a variety of different JavaScript frameworks. It should not be used as a reference about what framework is superior since not every framework follows the same route and has the same objectives. Before jumping to conclusion, you should read more sources and also hear every site. There are good reasons for dojo not having the $ operator and some interesting points can be found here (in the comments). When you need to decide which framework to chose, base your decision on your specific task and the framework you’re most comfortable with. The PHP backend

cpanel
ThisIsMine asked:


Please..I’m desperate.. I’m just an intern and I need to figure this out! Haha…
It’d be great if someone could chat online with me right now and walk me through this if you have a few minutes…
Thank you :)
kerfufle asked:


Web hosting cPanel tutorial showing how to enable SpamAssassin for your domain emails.

mysql
Anil Khatri asked:


Gone are the days of expensive web hosting. There was a time, just a few years ago, when hosting was not as cheap as it is now. Lets see why.

Hosting is all about storage on a hard disk (which resides on the web server) and bandwidth for your data. Till a few years ago, hard disk storage was not as large as it is now. Now-a-days hard disk drives come in a typical 400 GB to 500 GB capacity ranges. Even the smallest ones for home computer usage come in over 100 GB sizes. Compare that with a 40 GB hard drive just a few years ago.

A few of these 400 GB to 500 GB range hard disk drives in a typical Linux powered web server with 4 Intel Xeon Central Processing Units gives more than enough processing power and storage capacity to host hundreds of websites on one server, all of them running happily.

Throw in open source (free) Apache + PHP + MySQL combination and you have a recipe for hosting a real working dynamic website at very low costs. What was once a premium combination is now very standard and very cheap and very affordable. It is not uncommon to find hosting plans as cheap as just 99 cents per month, which come complete with all features including PHP and MySQL and enough storage + bandwidth.

There is, thus, no reason for anyone who wants to host anything from a personal homepage or a home business / small business wanting a dynamic website for their online business, to go only for simple HTML websites. No. That is long gone.

Shared web hosting has become very affordable for every kind of use and application. As storage and processing technology advances, hosting will be available with even better capacities and more powerful features. It makes complete sense to use the power of PHP and MySQL when it is well within everyone’s reach.

cpanel
simon s asked:


i have a website hosted on apache server ie linux based server .since i am not good at using the cpanel ,can any webmaster help me out to paste the html codes so that i can have those ebusiness and logos uploaded in my websites.
i have been doing it in blogs so far since its quite easy but with websites i am not familiar.

in which icon should i click in the cpanel and where should i go and paste those html codes

mysql
Rob asked:


I’m fetching results form a MySQL query using PHP. In my while loop I’m using a switch statement to execute blocks of code based on the results of a certain field type. After I have retrieved all the results for based on a certain field, I need to execute one last bit of code. Is their a way to tell if the row returned by the MySQL query is the last row matching a certain field? I figure it would be best to use an if statement to test if the result is the last row matching a certain field and execute my remaining code. Any other suggestions?
Apr
17
noamrachmany asked:


Delphi for PHP mysql dbevent sample

mysql
smasher2000 asked:


I want to start using PHP and mySQL to help me with my work. Does anyone know if and how I can set up somewhere locally on my computer or something where i can test my pages and database as if it were live on a web server?
cpanelvids asked:


cPanel Conference 2007 - Nameserver session excerpt.

Apr
14
Filed Under (Other - Computers) by Nick
cpanel
Bob Willis asked:


An entrepreneur who has just embarked on an online business may not be familiar with the terms associated with web hosting as well as with a website. A webmaster newbie may not be aware what a cpanel is. Actually when you sign in with a web hosting company, the web hosting package will include a control panel which you will use in managing and maintaining your files and your domain. Of course there are other control panel options but cpanel is most favored by internet marketers due to several reasons.

First off is the ease by which the domains can be managed. From a central location the domain names and files can be easily managed by the web master. Cpanel is considered to be the most user friendly option these days as web statistics like AW stats, FTP stats and bandwidth usage can be easily accessed. Cpanel is so designed so that the visitors to the website can be monitored. Additionally, the country of origin of the visitors can be shown. This is most important for an ecommerce site.

Cpanel makes it possible for you to manage your email accounts. Auto responders, mail forwarding, spam filtering is important for a website dedicated for an online business. The webmail feature makes is possible for you to check your email from any computer.

With cpanel on your web hosting control panel, you can easily build as well as edit your web pages, create changes to the search engine submission and program automated tasks to effects a task at a given time schedule.

Another great feature of cpanel that most webmasters find very useful is its ability to start the preinstalled scripts for chats and forums. The Fantastico enabled cpanel deal with 50 different scripts that facilitate the installation of Content Management Systems and other common scripts.