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

Your name:

Reply:


Posted by windandwaves on 07/13/05 02:33

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
reasons)
- 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
}

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация