Monday, November 11, 2013

Nesting with columns named id and parent_id

Create table mytable :

CREATE TABLE IF NOT EXISTS `mytable` (
  `id` int(11) NOT NULL,
  `parent_id` int(11) NOT NULL,
  `name` varchar(256) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `mytable`
--

INSERT INTO `mytable` (`id`, `parent_id`, `name`) VALUES
(1, 0, 'item 1'),
(2, 1, 'item 2'),
(3, 2, 'item 3');

And then run following script

Sunday, August 18, 2013

Connecting Two Derived Table

You want to join results from two queries - the derived tables are solution for you.
Look at code below.Yellow highlighted lines are queries that you want to join and green highlighted

Thursday, July 18, 2013

Execute Linux Commands from Browser

If you need to execute a shell command using browser here's how to do it. To understand this tutorial you need to have advanced level of understanding of Linux and PHP.

Wednesday, July 10, 2013

PHP debugging with JavaScript Console, Error and Access Log

You can use JavaScript console to output global and other variables from your PHP file. That way you can use JS console to track what is is going on in PHP backed files that are called by $.ajax. Also you should be familiar with PHP's functions utf8_encode and utf8_decode

Raw outuput of JSON string and Base64 encoded JSON string

Sunday, July 7, 2013

JSONP Tutorial

This is an advanced tutorial with working example you must know jQuery and JSONP foundations. JSONP bypass browser's "same origin" policy.

Tuesday, July 2, 2013

Parse JSON generated by PHP

This tutorial shows how to parse a JSON string generated by PHP. Place job.php and index.html in same folder.

Wednesday, June 26, 2013

Top 3 Apache Rewrite Tips

Maintenance

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/maintenance.html
RewriteRule (.*) /maintenance.html [R]

Serve page without 302 redirect

RewriteEngine on
RewriteBase /
RewriteRule ^oldpage\.html$ newpage.html [L] 

Serve page with 302 redirect

RewriteEngine on
RewriteBase /
RewriteRule ^oldpage\.html$ newpage.html [R,L]