PHP MySQL Web Interface

Problem

Having written a ga-zillian scripts, to query dbs, decided it would be much simpler to call just one function multiple times, duh! 🙂

Then fulfilling business request after request – with many short php web pages calling the function. Decided to progressing this further – by removing the web page altogether (hitting the function via a wrapper). Let it handle the query, via variable parameters passed in on the HTTP GET.

This posed a bit of problem, pushing complexity on the enquirer. So then decided to write a web (interface) form to drive the function (wrapper) – which subsequently made the query. 🙂

All will become clear shortly! 🙂



Solution



Example


Following this link will help a bit, I hope! 🙂 mysql demo

This web interface prepares the fields, which are subsequently submitted to the function for you.

You may notice that run_q is a PHP script, this is so you can either e-mail links directly to the function (genericQuery.php) or to this interface (run_q.php).

For example:

This query selects all fields and rows with a limit of 2 rows, to be returned – directly submitted to the function.

Function:
MySQL Demo Query

The next example drives the interface, which can then be submitted to the function. Notice it pre-selects mysql as the db (this is just for demo purposes, the table does not exit and mysql db is not accessible as this user).

Interface:

MYSQL Web Interface

After the interface submits, the subsequent query to the function can be cut and paste from the browser address bar.

Also this interface shows all the possible functions, where you can get quite creative in your query – try it out.



Reference

[tags]PHP MySQL Web Interface, PHP Coding School[/tags]



Writing a wordpress plugin – 3 easy steps

Problem

You want to create a wordpress plugin, which substitutes your tags for HTML.



Solution

This was a million times easier than I thought it was going to be. 🙂

step 1: mkdir wordpress/wp-content/plugins/YourPluginName

step 2: vi wordpress/wp-content/plugins/YourPluginName/Your Plugin Name.php

step 3: activate your plugin



Example


Here I want to substitute the following tags, with content wrapping.

[problem] … [/problem]

Put simply 😉


/*

Plugin Name: php-coding-school
Plugin URI: http://php.coding-school.com/php-coding.school.php
Description: wraps content, etc
Version: 1.0
Author: marcus
Author URI: http://php.coding-school.com

*/

add_filter('the_content', 'mp_wrap_content');

function mp_wrap_content($content) {

$search_strings='Your pattern to replace';

$end_strings='Your replacement';

$content = str_replace($search_strings,$end_strings, $content);
...
return $content;

}
?>



Reference

Used everywhere on this site, including this post itself. 🙂

[tags]Wordpress Plugin Tutorial, PHP Coding School[/tags]