Mysql Order / Sort by before Group by

Every developer knows the horror of mysql sort/order by or select distinct using with group by. Mysql does group by before order by and you get mixed results not what you expected. This is a small solution with less performance problem:

SELECT * FROM 

(
select * from `my_table` order by timestamp desc
) as my_table_tmp

group by catid

order by nid desc

In this example we get latest news in each category. We create a temp table by sorting by timestamp and group by after it. It worked for me.

Tags:

Bing vs. Google: a small comparison

Bing vs. Google
This is a small comparison between Google and Microsoft's new search engine Bing. I tried to compare most used features for web search and results quality. Quality of image and video search like common services would be the point of next article.

Google's goal is simplicity and experience. Google's huge stats make available to find relation between different search terms. Bing's goal is Curiosity. People want to see what can a Google-competitor search engine do.

Photo Album / Picture Gallery Script with PHP


This is a all-in-one-file small and powerful image gallery script with PHP. Just upload your images to directory of script with FTP. It is free for private use. For a demo click on screenshot-image.

Features:

  • Scann directory and display images in web formats automagically
  • Create thumbnail images dynamically on the fly (from all JPEG, GIF, PNG)
  • Sort images by name, size or last modified time

Simple Hello World Module for Drupal 6

This is a small and simple "Hello World!" module for quickstarters who uses Drupal 6x series. We need just one directory and two files:

  • modules/simple_hello_world/
  • modules/simple_hello_world/simple_hello_world.info
  • modules/simple_hello_world/simple_hello_world.module

modules/simple_hello_world/simple_hello_world.info

; $Id$
name = Simple Hello World
description = Description of Simple Hello World module
core = 6.x

modules/simple_hello_world/simple_hello_world.module

<?php

Comparison of free Shopping Carts - 2009

This is a comparison of free -mostly open source- "shopping carts" / "e-commerce systems": Magento, osCommerce , Virtuemart (+ Joomla), Ubercart (+ Drupal), X-Cart , Zen Cart , ShopCMS , CS-Cart , Cube Cart , eCommerce Framework G5 (ECF), Ecommerce Templates , FlyingCart, Go Ecommerce EShop Builder , Interspire Shopping Cart , iScripts Multicart , JadaSite , JShop , LiteCommerce , PhPepperShop, PrestaShop, ProductCart , Ecommerce Shopping Cart Software , VP-ASP Shopping Cart , WebAsyst Shop-Script , Zeus Cart (AJ Shopping Cart).

Check password safety with JavaScript while typing

You can show password strength to your visitors while typing before even submitting the page to the webserver. There are four character groups: letters, caps, numbers and symbols. A password which is longer than 7 characters and contains at least one character from each group is strong vz537gnjua. A password which is at least 8 character long and has all characters from one group is weak (but not very weak). A password which contains all characters from one group and at least 20 characters long is also strong.

Register Globals Emulator for PHP

If your webhosting turned register-globals off and you are still using a script/software which requires register-globals on you have a problem. But there is an easy solution: Just put this code at the top of your php script(s). Attention!!! "register_globals=on" means a huge security risk. Do not turn it on unless you know what are you doing!
Technorati Profile

foreach(array($_GET, $_POST, $_COOKIE) as $k=>$v){
	foreach($v as $k2=>$v2){
		$$k2 = $v2;
	}
}

CSS Text effects for MSIE

Here are some cool css text effects for microsoft internet explorer. You can use them with images too.
Tags:

Repair all mysql databases-tables with PHP

phpMyAdmin is a great tool but there is no option to repair all databases at once yet. Imagine you have no shell-access and need to repair all your 100 databases. It would take long time. This small PHP-Script lets you list, analyze and repair all your databases belong to same user at once.

If you already have shell access you can do it with mysqlcheck:

mysqlcheck -u root -p --auto-repair --check --optimize --all-databases


Repair with PHP:

  

Find top level domain from international urls with PHP

The format of both "sub.tld.org" and "tld.org.gr" is similar for php. But one of them is top level domain and the other one is a subdomain. explode(".", $tld) is not enaugh to find real tld in this case. This function helps to dedect all known tlds including multi-level regional tlds. It could be useful for fraud dedection or finding duplicate sites under different tlds.

<?php 

/**
*	powered by @cafewebmaster.com
*	free for private use
*	please support us with donations
*/

function find_tld($url){

$purl  = parse_url($url);
$host  = $purl[host];
Syndicate content

CafeWebmaster.com(CW) is a free online community for webdevelopers and beginners. Anybody can share their code, articles, tips, tutorials, code-examples or other webdesign related material on the site. Newbies can submit their questions and reply to existing questions. CW does not guarantee or warrant reliability of code, data and information published on the site. Use the site on your own risk. The site takes no responsibility of direct or indirect loss or any kind of harm to its users. The site also doesn't take responsibility of infected files or source code with any kind of infection or viruses, worms, spywares, malwares, trojan horses. CW reserves the right to edit, move, or delete any of content for any reason.