Archive for March, 2007

Insert and Update in one query

Friday, March 30th, 2007

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 :)

BritePic

Friday, March 30th, 2007

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.

Link: BritePic

Mapbender

Tuesday, March 6th, 2007

Map Bender

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.

If you’d like to take a look at a sample, check out this link: http://wms1.ccgis.de/mapbender2/frames/index.php?&gui_id=mapbender

Link: Main Page - MapbenderWiki
Download : http://www.mapbender.org/index.php/Download_Mapbender
Installation Instructions: http://www.mapbender.org/index.php/Installation_en
Mapbender Gallery: http://www.mapbender.org/index.php/Mapbender_Gallery

miniajax.com

Monday, March 5th, 2007

miniajax.com

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

  • Ajax StarRating
  • Ajax Contact Form
  • In-place editing (like Flickr)
  • Bubble Tool-tips
  • Heatmap for websites and much more…

Link: miniajax.com

dBug

Thursday, March 1st, 2007

dBug

dBug is a variable dump tool, similar to Cold Fusion’s cfdump, for PHP which provides the following:

  • Outputs colored and structured tabular variable information.
  • Variable types supported are: Arrays, Classes/Objects, Database and XML Resources.
  • Ability to force certain types of output. Example: You can force an object variable to be outputted as an array type variable.

Integrating it with your code is as simple as the code shown below:

include_once("dBug.php");
new dBug($myVariable);

Link: dBug

About Me

Here's my blog on stuff I keep finding on the Web. More

Want to subscribe?

 Subscribe in a reader Or, subscribe via email:
Enter your email address:  
On the Go? Get this on your Widsets: Add to my Widsets
Find entries :