Here’s a quick tip in MySQL. Let’s say you have a table called browsercount like the one below:
id
browser
count
1
Internet Explorer
1
2
Opera
2
Let’s say you have a web-analytic application which has to add a browser into the table if it doesn’t exist, but update the count for the browser if the entry already exists. How do you go about that?
The usual way would be to first query the table to see if the entry exists, then fire an insert statement or an update statement based on the results.
Here’s how to perform the same action in one SQL statement:
INSERT INTO browsercount (browser,count) VALUES ('Firefox',1) ON DUPLICATE KEY UPDATE count=count+1;
This will work if the id field in the table above is declared as UNIQUE or is a Primary Key.
The query basically tells mysql to insert the data into the database, but if a duplicate key is found, increment the count field by 1. It’s much faster than firing up 2 sql queries from your PHP script
Here’s a new service from BritePic which allows you to add interactivity to the images on your site, and at the same time make some $$. BritePic allows you to place advertisements in your images, and allow users to zoom, email, create links to your images.
Here’s a sample image served by BritePic:
So instead of using the plain ol’ img tag to place your images in the page, use the BritePic way, good for you and your visitors
The BritePic code allows you to control the image size, image caption, keywords and the link to send the visitors to when they click on the image. You can choose whether you want ads displayed in the images. The ads appear in the image if AdBite has ads based on the keywords you supply for the image.
BritePic is a part of the Adbrite advertisement network.
Looking for a way to integrate maps into your PHP application without using Google Maps? Here’s an open source project powered by PHP which allows you to do just that.
Mapbender allows you to zoom in & out, pan, click and query, turn layers on and off on a map. You can also add new points to the map with the flag button. The application doesn’t have it’s own maps but gets them from external map services.
Miniajax.com is a showcase ofwhat’s hot in Ajax, with link to demos and tutorials showing how they’re done. Here are some of what you can see at miniajax.com