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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • windandwaves

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

    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_descripto r().'` FROM `'.$table.'` '.$sqlw.'
    ORDER BY `'.dd_descripto r().'`;';
    $query = mysql_query($sq l);
    $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
    }


  • SOR

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

    <comp.lang.ph p , windandwaves , winandwaves@col dmail.com>
    <VrYAe.125$PL5. 48345@news.xtra .co.nz>
    <Wed, 13 Jul 2005 11:33:59 +1200>
    [color=blue]
    > 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?
    >[/color]

    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 .

    Comment

    • windandwaves

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

      SOR wrote:[color=blue]
      > <comp.lang.ph p , windandwaves , winandwaves@col dmail.com>
      > <VrYAe.125$PL5. 48345@news.xtra .co.nz>
      > <Wed, 13 Jul 2005 11:33:59 +1200>
      >[color=green]
      >> 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?
      >>[/color]
      >
      > MySQL Administrator is a windows app[/color]

      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

      Nicolaas


      Comment

      Working...