백엔드 개발 PHP 튜토리얼 一个SQL管理员的web接口_PHP教程

一个SQL管理员的web接口_PHP教程

Jul 21, 2016 pm 04:03 PM
sql web 인터페이스 ~의 관리자

   
    /*************************************************************************************  
     *        SQLAdmin  v2.0  -  An  SQL  Administration  User  Interface  for  the  Web *   
     *            Copyright  (C)  1997-98    Alessandro  Vernet        *   
     *************************************************************************************   
     *      This  library  is  free  software;  you  can  redistribute  it  and/or       *   
     *      modify  it  under  the  terms  of  the  GNU  Library  General  Public        *   
     *      License  as  published  by  the  Free  Software  Foundation;  either         *   
     *      version  2  of  the  License,  or  (at  your  option)  any  later  version.  *   
     *                                                                                   *   
     *      This  library  is  distributed  in  the  hope  that  it  will  be  useful,   *   
     *      but  WITHOUT  ANY  WARRANTY;  without  even  the  implied  warranty  of      *   
     *      MERCHANTABILITY  or  FITNESS  FOR  A  PARTICULAR  PURPOSE.    See  the  GNU  *   
     *      Library  General  Public  License  for  more  details.                       *   
     *                                                                                   *   
     *      You  should  have  received  a  copy  of  the  GNU  Library  General  Public *   
     *      License  along  with  this  library;  if  not,  write  to  the               *   
     *      Free  Software  Foundation,  Inc.,  59  Temple  Place  -  Suite  330,        *   
     *      Boston,  MA    02111-1307,  USA.                                             *   
     *************************************************************************************/   


    /*  TODO:   
      *  -  Add  sort  order.   
      *  -  Add  simple  view.   
      *  -  Add  some  documentation.   
      */   

    /*  LIMITATIONS:   
      *  -  Works  only  with  mSQL.   
      */   

    /*  HISTORY:   
      *  -  97-11-05  (avernet)  Corrected  a  bug  with  quote.   
      *  -  98-01-01  (avernet)  Added  a  sortColumn  parameter  to   
      *      administrationTable  function.   
      *  -  98-03-14  (avernet)  Added  function  addTable  to  enable  users  to   
      *      add  (but  not  modify)  en  entry  to  the  database.   
      *  -  98-05-19  (avernet)  Submitted  to  PX.   
      *  -  98-10-11  (avernet)  Now  SQLAdmin  works  with  PHP3.  The  PHP2  version   
      *      will  not  be  mainteained  anymore.   
      *  -  98-10-11  (avernet)  SQLAdmin  is  now  distributed  under  the  LGPL   
      *      instead  of  MPL.   
      */   

    function  escapeforhtml  ($string)   
    {   
        $result  =  $string;   
        //$result  =  ereg_replace  ("\"",  """,  $result);   
        $result  =  ereg_replace  ("        $result  =  ereg_replace  (">",  ">",  $result);   
        return  $result;   
    }   

    function  displayTuple  ($fieldsNumber,  $fieldNames,   
                                                  $fieldLengths,  $values,  $mode)   
    {   
        $result  =  "";   
        $result  .=  "

"  .   
            "
";   
        $result  .=  "";   
        $fieldIndex  =  0;   
        while  ($fieldIndex          {   
            $result  .=  "";   
            $fieldIndex++;   
        }   
        $result  .=  "
"  .  $fieldNames  [$fieldIndex]  .  " ";   
            if  ($fieldLengths  [$fieldIndex]              {   
                $result  .=  "                    $fieldNames  [$fieldIndex]  .  "\"  VALUE=\""  .   
                    $values  [$fieldIndex]  .  "\"  SIZE=\"64\">";   
            }   
            else   
            {   
                $result  .=  "";   
            }   
            $result  .=    "                $fieldNames  [$fieldIndex]  .   
                "\"  VALUE=\""  .  escapeforhtml  ($values  [$fieldIndex])  .  "\">"  .   
                "
";   
        if  ($mode  ==  "modify")   
        {   
            $result  .=  "";   
            $result  .=  "";   
        }   
        else   
            {  $result  .=  "";  }   
        $result  .=  "
";   
        return  $result;   
    }   

    function  fieldFromType  ($text,  $type)   
    {   
        if  ($type  ==  "int"  ||  $type  ==  "uint"  ||  $type  == "real")   
            {  $result  =  $text;  }   
        else   
            {  $result  =  "'"  .  AddSlashes  ($text)  .  "'";  }   
        return  $result;   
    }   

    function  executeMsql  ($database,  $command)   
    {   
        /*echo  ""  .  $command  .  "
";*/   
        msql  ($database,  $command);   
    }   

    function  handleRemove  ($database,  $table,  $fieldsNumber,   
                                                  $fieldNames,  $fieldLengths,  $fieldTypes)   
    {   
        global  $remove;   
        if  ($remove  !=  "")   
        {   
            $command  =  "DELETE  FROM  "  .  $table  .  "  WHERE  ";   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $fieldName  =  "old-"  .  $fieldNames  [$fieldIndex];   
                global  $$fieldName;   
                $command  .=  $fieldNames  [$fieldIndex]  .  "="  .   
                    fieldFromType  ($$fieldName,  $fieldTypes  [$fieldIndex]);   
                if  ($fieldIndex  !=  $fieldsNumber  -  1)   
                    {  $command  .=  "  AND  ";  }   
                $fieldIndex++;   
            }                  
            executeMsql  ($database,  $command);   
        }   
    }   

    function  handleUpdate  ($database,  $table,  $fieldsNumber,   
                                                  $fieldNames,  $fieldLengths,  $fieldTypes)   
    {   
        global  $update;   
        if  ($update  !=  "")   
        {   
            $command  =  "UPDATE  "  .  $table  .  "  SET  ";   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $fieldName  =  $fieldNames  [$fieldIndex];   
                global  $$fieldName;   
                $command  .=  $fieldName  .  "="  .   
                    fieldFromType  ($$fieldName,  $fieldTypes  [$fieldIndex]);   
                if  ($fieldIndex  !=  $fieldsNumber  -  1)   
                    {  $command  .=  ",  ";  }   
                $fieldIndex++;   
            }   
            $command  .=  "  WHERE  ";   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $fieldName  =  "old-"  .  $fieldNames  [$fieldIndex];   
                global  $$fieldName;   
                $command  .=  $fieldNames  [$fieldIndex]  .  "="  .   
                    fieldFromType  ($$fieldName,  $fieldTypes  [$fieldIndex]);   
                if  ($fieldIndex  !=  $fieldsNumber  -  1)   
                    {  $command  .=  "  AND  ";  }   
                $fieldIndex++;   
            }   
            executeMsql  ($database,  $command);   
        }   
    }   

    function  handleAdd  ($database,  $table,  $fieldsNumber,   
                                            $fieldNames,  $fieldLengths,  $fieldTypes)   
    {   
        global  $add;   
        if  ($add  !=  "")   
        {   
            $command  =  "INSERT  INTO  "  .  $table  .  "  (";   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $command  .=  $fieldNames  [$fieldIndex];   
                if  ($fieldIndex  !=  $fieldsNumber  -  1)   
                    {  $command  .=  ",  ";  }   
                $fieldIndex++;   
            }   
            $command  .=  ")  VALUES  (";   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $fieldName  =  $fieldNames  [$fieldIndex];   
                global  $$fieldName;   
                $command  .=  fieldFromType  ($$fieldName,  $fieldTypes  [$fieldIndex]);   
                if  ($fieldIndex  !=  $fieldsNumber  -  1)   
                    {  $command  .=  ",  ";  }   
                $fieldIndex++;   
            }   
            $command  .=  ")";   
            executeMsql  ($database,  $command);   
        }   
    }   

    function  displayRemoveUpdate  ($database,  $table,  $sortColumn,   
                                                                $fieldsNumber,  $fieldNames,  $fieldLengths)   
    {   
        $result  =  "";   
        if  ($sortColumn  !=  "")   
            {  $sortColumn  =  "  ORDER  BY  "  .  $sortColumn;  }   
        $msqlresult  =  msql  ($database,  "SELECT  *  FROM  "  .  $table  .  $sortColumn);   
        $tuplesNumber  =  msql_numrows  ($msqlresult);   
        $tupleIndex  =  0;   
        while  ($tupleIndex          {   
            $fieldIndex  =  0;   
            while  ($fieldIndex              {   
                $values  [$fieldIndex]  =  msql_result  ($msqlresult,  $tupleIndex,   
                    $fieldNames  [$fieldIndex]);   
                $fieldIndex++;   
            }   
            $result  .=  displayTuple  ($fieldsNumber,  $fieldNames,   
                $fieldLengths,  $values,  "modify");   
            $tupleIndex++;   
        }   
        return  $result;   
    }   

    function  displayAdd  ($fieldsNumber,  $fieldNames,  $fieldLengths)   
    {   
        $result  =  "";   
        $fieldIndex  =  0;   
        while  ($fieldIndex          {   
            $values  [$fieldIndex]  =  "";   
            $fieldIndex++;   
        }   
        $result  .=  displayTuple  ($fieldsNumber,  $fieldNames,   
            $fieldLengths,  $values,  "add");   
        msql_close  ();   
        return  $result;   
    }   

    function  administrationTable  ($database,  $table,  $sortColumn)   
    {   
        $result  =  "";   
        msql_connect  ( "localhost");   
        $msqlresult  =  msql  ($database,  "SELECT  *  FROM  "  .  $table);   
        $fieldsNumber  =  msql_numfields  ($msqlresult);    
        $msqlresult  =  msql_listfields  ($database,  $table);   
        $fieldIndex  =  0;   
        while  ($fieldIndex          {   
            $fieldNames  [$fieldIndex]  =  msql_fieldname  ($msqlresult,  $fieldIndex);   
            $fieldLengths  [$fieldIndex]  =  msql_fieldlen  ($msqlresult,  $fieldIndex);   
            $fieldTypes  [$fieldIndex]  =  msql_fieldtype  ($msqlresult,  $fieldIndex);   
            $fieldIndex++;   
        }   
        handleRemove  ($database,  $table,  $fieldsNumber,  $fieldNames,  $fieldLengths,  $fieldTypes);   
        handleUpdate  ($database,  $table,  $fieldsNumber,  $fieldNames,  $fieldLengths,  $fieldTypes);   
        handleAdd  ($database,  $table,  $fieldsNumber,  $fieldNames,  $fieldLengths,  $fieldTypes);   
        $result  .=  displayRemoveUpdate  ($database,  $table,  $sortColumn,  $fieldsNumber,  $fieldNames,    
$fieldLengths);   
        $result  .=  displayAdd  ($fieldsNumber,  $fieldNames,  $fieldLengths);   
        return  $result;   
    }   

    function  addTable  ($database,  $table)   
    {   
        $result  =  "";   
        msql_connect  ( "localhost");   
        $msqlresult  =  msql  ($database,  "SELECT  *  FROM  "  .  $table);   
        $fieldsNumber  =  msql_numfields  ($msqlresult);    
        $msqlresult  =  msql_listfields  ($database,  $table);   
        $fieldIndex  =  0;   
        while  ($fieldIndex          {   
            $fieldNames  [$fieldIndex]  =  msql_fieldname  ($msqlresult,  $fieldIndex);   
            $fieldLengths  [$fieldIndex]  =  msql_fieldlen  ($msqlresult,  $fieldIndex);   
            $fieldTypes  [$fieldIndex]  =  msql_fieldtype  ($msqlresult,  $fieldIndex);   
            $fieldIndex++;   
        }   
        handleAdd  ($database,  $table,  $fieldsNumber,  $fieldNames,  $fieldLengths,  $fieldTypes);   
        $result  .=  displayAdd  ($fieldsNumber,  $fieldNames,  $fieldLengths);   
        return  $result;   
    }   
?>   

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/316182.htmlTechArticle? /************************************************************************************* *SQLAdminv2.0-AnSQLAdministrationUserInterfacefortheWeb * *Copyright(C)1997-98AlessandroVern...
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Windows 11에서 계속하려면 관리자 사용자 이름과 비밀번호를 입력하라는 메시지가 표시되는 문제를 해결하는 방법은 무엇입니까? Windows 11에서 계속하려면 관리자 사용자 이름과 비밀번호를 입력하라는 메시지가 표시되는 문제를 해결하는 방법은 무엇입니까? Apr 11, 2024 am 09:10 AM

Win11 시스템을 사용할 때 관리자 사용자 이름과 비밀번호를 입력하라는 메시지가 표시되는 경우가 있습니다. 이 문서에서는 이 상황을 처리하는 방법에 대해 설명합니다. 방법 1: 1. [Windows 로고]를 클릭한 다음 [Shift+다시 시작]을 눌러 안전 모드로 들어가거나 이 방법으로 안전 모드로 들어갑니다. 시작 메뉴를 클릭하고 설정을 선택합니다. "업데이트 및 보안"을 선택하고 "복구"에서 "지금 다시 시작"을 선택한 후 옵션을 입력하고 - 문제 해결 - 고급 옵션 - 시작 설정 -&mdash를 선택하세요.

Hibernate 프레임워크에서 HQL과 SQL의 차이점은 무엇입니까? Hibernate 프레임워크에서 HQL과 SQL의 차이점은 무엇입니까? Apr 17, 2024 pm 02:57 PM

HQL과 SQL은 Hibernate 프레임워크에서 비교됩니다. HQL(1. 객체 지향 구문, 2. 데이터베이스 독립적 쿼리, 3. 유형 안전성), SQL은 데이터베이스를 직접 운영합니다(1. 데이터베이스 독립적 표준, 2. 복잡한 실행 파일) 쿼리 및 데이터 조작).

Oracle SQL의 나누기 연산 사용법 Oracle SQL의 나누기 연산 사용법 Mar 10, 2024 pm 03:06 PM

"OracleSQL의 나눗셈 연산 사용법" OracleSQL에서 나눗셈 연산은 일반적인 수학 연산 중 하나입니다. 데이터 쿼리 및 처리 중에 나누기 작업은 필드 간의 비율을 계산하거나 특정 값 간의 논리적 관계를 도출하는 데 도움이 될 수 있습니다. 이 문서에서는 OracleSQL의 나누기 작업 사용법을 소개하고 구체적인 코드 예제를 제공합니다. 1. OracleSQL의 두 가지 분할 연산 방식 OracleSQL에서는 두 가지 방식으로 분할 연산을 수행할 수 있습니다.

Oracle과 DB2의 SQL 구문 비교 및 ​​차이점 Oracle과 DB2의 SQL 구문 비교 및 ​​차이점 Mar 11, 2024 pm 12:09 PM

Oracle과 DB2는 일반적으로 사용되는 관계형 데이터베이스 관리 시스템으로, 각각 고유한 SQL 구문과 특성을 가지고 있습니다. 이 기사에서는 Oracle과 DB2의 SQL 구문을 비교 및 ​​차이점을 설명하고 구체적인 코드 예제를 제공합니다. 데이터베이스 연결 Oracle에서는 다음 문을 사용하여 데이터베이스에 연결합니다. CONNECTusername/password@database DB2에서 데이터베이스에 연결하는 문은 다음과 같습니다. CONNECTTOdataba

Win11에서 관리자 권한을 얻는 방법 요약 Win11에서 관리자 권한을 얻는 방법 요약 Mar 09, 2024 am 08:45 AM

Win11 관리자 권한을 얻는 방법에 대한 요약 Windows 11 운영 체제에서 관리자 권한은 사용자가 시스템에서 다양한 작업을 수행할 수 있도록 하는 매우 중요한 권한 중 하나입니다. 때로는 소프트웨어 설치, 시스템 설정 수정 등과 같은 일부 작업을 완료하기 위해 관리자 권한을 얻어야 할 수도 있습니다. 다음은 Win11 관리자 권한을 얻는 몇 가지 방법을 요약한 것입니다. 도움이 되기를 바랍니다. 1. 단축키를 사용하세요. Windows 11 시스템에서는 단축키를 통해 명령 프롬프트를 빠르게 열 수 있습니다.

컴퓨터 마더보드의 내부 인터페이스는 무엇입니까? 컴퓨터 마더보드의 내부 인터페이스에 대한 권장 소개 컴퓨터 마더보드의 내부 인터페이스는 무엇입니까? 컴퓨터 마더보드의 내부 인터페이스에 대한 권장 소개 Mar 12, 2024 pm 04:34 PM

컴퓨터를 조립할 때 설치 과정은 간단하지만 배선에 문제가 발생하는 경우가 종종 있습니다. 컴퓨터가 켜지면 F1 오류 "CPUFanError"가 발생하며 이로 인해 CPU 쿨러가 지능적으로 속도를 조정할 수 없게 됩니다. 컴퓨터 마더보드의 CPU_FAN, SYS_FAN, CHA_FAN, CPU_OPT 인터페이스에 대한 상식을 공유해 보겠습니다. 컴퓨터 마더보드의 CPU_FAN, SYS_FAN, CHA_FAN 및 CPU_OPT 인터페이스에 대한 대중적인 과학 1. CPU_FANCPU_FAN은 CPU 라디에이터 전용 인터페이스이며 12V에서 작동합니다.

데이터베이스 기술 경쟁: Oracle과 SQL의 차이점은 무엇입니까? 데이터베이스 기술 경쟁: Oracle과 SQL의 차이점은 무엇입니까? Mar 09, 2024 am 08:30 AM

데이터베이스 기술 경쟁: Oracle과 SQL의 차이점은 무엇입니까? 데이터베이스 분야에서 Oracle과 SQL Server는 매우 존경받는 관계형 데이터베이스 관리 시스템입니다. 둘 다 관계형 데이터베이스 범주에 속하지만 둘 사이에는 많은 차이점이 있습니다. 이 기사에서는 Oracle과 SQL Server의 차이점과 실제 애플리케이션에서의 기능 및 장점을 자세히 살펴보겠습니다. 우선, Oracle과 SQL Server 사이에는 구문에 차이가 있습니다.

PHP 인터페이스 소개 및 정의 방법 PHP 인터페이스 소개 및 정의 방법 Mar 23, 2024 am 09:00 AM

PHP 인터페이스 소개 및 정의 방법 PHP는 웹 개발에 널리 사용되는 오픈 소스 스크립팅 언어입니다. 유연하고 간단하며 강력합니다. PHP에서 인터페이스는 여러 클래스 간의 공통 메서드를 정의하여 다형성을 달성하고 코드를 보다 유연하고 재사용 가능하게 만드는 도구입니다. 이 기사에서는 PHP 인터페이스의 개념과 이를 정의하는 방법을 소개하고 사용법을 보여주는 특정 코드 예제를 제공합니다. 1. PHP 인터페이스 개념 인터페이스는 클래스 애플리케이션을 정의하는 객체 지향 프로그래밍에서 중요한 역할을 합니다.

See all articles