php my admin - reinventing the wheel - mysql front-end

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi Folk

I am an PHP novice.

Right now, I am redeveloping the wheel by creating my own type of PHP  
MyAdmin tool for my clients so that they can manage some data.  A good  
exercise, but probably done before!

My question: is there something out there similar to what I describe below  
or how do you go about it (I am sure that all of you have faced this problem  
before)?  How do you recommend I proceed?

PHP MyAdmin would not be suitable for my clients, because it contains too  
much and it is too technical (e.g. i dont want them to change the structure  
of the database).

So far, I have created a simple structure that allows the user to edit any  
table in my database.  Here is an overview of how I do it.  If anyone wants  
a copy of the files, please email me php at ngaru dot com.

[1] list.php  - shows the data from a table in a list - allowing users to
 a. delete a row
 b. click on a field for a related id items (they are shown as meaningful  
data from the look-up table rather than the id).  For example in the list of  
customers, the city is shown as the name of the city rather than the city id  
(linked table)
 c. click on the edit button for any row

[2] edit.php (shows a form where you can either add or update a row)
 a. provides the ability to "go-through" to child data (e.g. if you are in  
the customer table then you can click through to the customer order table  
for that customer).

[3] to make it all work, I have created a table DEF that defines the data  
structure.  While I have not formally created relationships in the MySql  
database (I do not know how to), this table shows them, because a field like  
LIS_ID relates back tot the LIS table and a field CAM_ID relates back to the  
CAM table.  The DEF table describes each field with:
- name of the table it belongs to (e.g. CAM)
- field name (e.g NAM)
- field name to be used as ID in a form (e.g. campaignname) - to avoid  
people knowing the exact names of the fields in the database (for security  
- field name to be used for users (e.g. Campaign Name)
- function used to validate an entry in the edit form for this field

The beauty is that, using this DEF table, the list.php and the edit.php  
pages can be created for any table in the database.  Those fields and tables  
that are admin only I simply leave out of the DEF table.

I have also written the little function below to create a dropdown list for  
look-up fields.

//creates a dropdown for a table
function dd($table, $name, $class, $select){
 $sqlw = dd_where($table, dd_restricter() );
 $sql = 'SELECT `ID`, `'.dd_descriptor().'` FROM `'.$table.'` '.$sqlw.'  
ORDER BY `'.dd_descriptor().'`;';
 $query = mysql_query($sql);
 $v = '<SELECT Name="'.$name.'" ID="'.$name.'" CLASS="'.$class.'">';
 while ( $row = mysql_fetch_row($query) ) {
  $v .= '<OPTION ';
  if ( $select && $row[0] == $select ) {
   $v .= ' SELECTED ';
  $v .= ' VALUE="'.$row[0].'">'.$row[1].'</OPTION>';
 $v .= "</SELECT>";
 return $v;

function dd_restricter () {
 //returns the name of the field that contains the most meaningful  
description for a record
function dd_where($t, $restrictt) {
 $id = sgd($restrictt.'_ID');
 $v = ' WHERE ';
 if($t == $restrictt ) {
  $v .= ' `ID` = "'.$id.'" ';
 else {
  if( is_parent($t, $restrictt) ) {
   $v .= ' `'.$restrictt.'` = "'.$id.'" ';
  else {
   $v = ' WHERE `ID` > -1 ';
 return $v;

function sgd ($fieldname) {
 //returns a user-specific value from the session table

Re: php my admin - reinventing the wheel - mysql front-end

<Wed, 13 Jul 2005 11:33:59 +1200>

Quoted text here. Click to load it

MySQL Administrator is a windows app and probably well worth a look as  
it will no doubt give you a few ideas on your custom layout and editing  
options .

Be sure and post a url if you get your custom editor working .

Re: php my admin - reinventing the wheel - mysql front-end

SOR wrote:
Quoted text here. Click to load it

I was actually more interested in PHP... but I will have a look.  I have not  
loaded MySql on my pc so it may be hard for me.

Thank you


Re: php my admin - reinventing the wheel - mysql front-end

<Wed, 13 Jul 2005 15:03:33 +1200>

Quoted text here. Click to load it

To be honest I aint sure if thats the right name for the app anyway or  
if it was called something else like it .

But the point was it was better and easier to use than phpmyadmin  
because of the layout design it had .

If your going to do a carbon copy of phpmyadmin would you not be better  
just altering/editing the actual phpmyadmin utility to suit .

Re: php my admin - reinventing the wheel - mysql front-end

Hello, windandwaves,

Sorry, I'm not able to answer your question.

I'm new to PHP and MySql, could you please share some links with me
where I could find source code for PHP and MySql.

Thank you in advance.

Site Timeline