Home Backend Development PHP Tutorial Basic operation code for adding, modifying and deleting database (1/4)_PHP tutorial

Basic operation code for adding, modifying and deleting database (1/4)_PHP tutorial

Jul 13, 2016 pm 05:04 PM
code Revise delete Base operate database payment Compare Add to Suitable

Basic operation codes for database addition, modification, and deletion This is a tutorial that is more suitable for PHP beginners. We use a simple example to add, modify, and delete the database, so that you can know the key points of PHP mysql database operations in a more systematic way.

Database tutorial to add, modify and delete basic operation codes
This is a tutorial that is more suitable for beginners to learn PHP tutorials. We use a simple example to add, modify, and delete the database, so that you can know the key points of database operations in the PHP mysql tutorial in a more systematic way.
*/
require_once('common.php');
$action = $_get['action'];
?>





人才列表


 
 


 

        if($action=='add'){
 ?>
   

 
         
           
         
           
         
         
           
           
         
         
           
           
         
          
           
           
         
           
             
           
             
     
添加人员
登陆账号
登陆密码
问题
答案

   

        }
      elseif($action=='save'){
    $login = isset($_post['login']) ? $_post['login'] : '';
    $pws = isset($_post['pws']) ? $_post['pws'] : '';
    $question = isset($_post['question']) ? $_post['question'] : '';
    $answer = isset($_post['answer']) ? $_post['answer'] : '';
    $sql = "insert into person (login,pws,question,answer)
    values('$login','$pws','$question','$answer')";
    $db->query($sql);
    forward('发布成功','href','personlist.php');
          }

    elseif($action=='del'){
    $person_id=$_get['person_id'];
    $page=$_get['page'];
    $sql="delete from person where person_id='$person_id'";
    $db->query($sql);
    forward('删除成功','href','personlist.php?page='.$page);
          } 
    elseif($action=='editsave'){
    $person_id = isset($_post['person_id']) ? $_post['person_id'] : '';
    $page = isset($_post['page']) ? $_post['page'] : '';
          $login = isset($_post['login']) ? $_post['login'] : '';
    $pws = isset($_post['pws']) ? $_post['pws'] : '';
    $question = isset($_post['question']) ? $_post['question'] : '';
    $answer = isset($_post['answer']) ? $_post['answer'] : '';
    $sql="update person set login='$login',pws='$pws',question='$question',answer='$answer' where person_id='$person_id'";
    $db->query($sql);
          forward('修改成功','href','personlist.php?page='.$page);
          }
   elseif($action=='edit'){
    $person_id=$_get['person_id'];
    $page=$_get['page'];
    $sql="select * from person where person_id='$person_id'";
    $query = $db->query($sql);
    $row = $db->fetch_array($query);
    $login=$row['login'];
    $pws=$row['pws'];
    $question=$row['question'];
    $answer=$row['answer'];
       ?>
   


 
         
         
         
           
         
           
         
         
           
           
         
         
           
           
         
          
           
           
         
           
             
           
             
     
修改人员
登陆账号
登陆密码
问题
答案

   

            }
      else{
          $page = isset($_get['page']) ?intval($_get['page']) : 1;
          $num = 5;
          $sql="select * from person";
          $query = $db->query($sql);
          $totalnum = $db->num_rows($query);//记录总数
          $pagenum = ceil($totalnum/$num); //总页数
          $offset = ($page-1) * $num;
          $sql=$sql." limit $offset,$num ";
          $query = $db->query($sql);//取得记录
        ?>
         
         
           
         
         
         
         
         
         
         
           while ($row = $db->fetch_array($query)) {
        ?>
         
         
           
           
           
           
           
         
                                                                                    }
          ?>
记录总数:————添加人员
登陆账号登陆密码问题答案加入时间操作
删除/
            修改


        

                   


}
?>



1 2 3 4

http://www.bkjia.com/PHPjc/630832.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630832.htmlTechArticleBasic operation code for database addition, modification, and deletion. This is a tutorial that is more suitable for PHP beginners. We Use a simple example to add, modify, and delete the database...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to completely delete TikTok chat history How to completely delete TikTok chat history May 07, 2024 am 11:14 AM

1. Open the Douyin app, click [Message] at the bottom of the interface, and click the chat conversation entry that needs to be deleted. 2. Long press any chat record, click [Multiple Select], and check the chat records you want to delete. 3. Click the [Delete] button in the lower right corner and select [Confirm deletion] in the pop-up window to permanently delete these records.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing Jun 12, 2024 pm 08:38 PM

Since the launch of ChatGLM-6B on March 14, 2023, the GLM series models have received widespread attention and recognition. Especially after ChatGLM3-6B was open sourced, developers are full of expectations for the fourth-generation model launched by Zhipu AI. This expectation has finally been fully satisfied with the release of GLM-4-9B. The birth of GLM-4-9B In order to give small models (10B and below) more powerful capabilities, the GLM technical team launched this new fourth-generation GLM series open source model: GLM-4-9B after nearly half a year of exploration. This model greatly compresses the model size while ensuring accuracy, and has faster inference speed and higher efficiency. The GLM technical team’s exploration has not

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Create Agent in one sentence! Robin Li: The era is coming when everyone is a developer Create Agent in one sentence! Robin Li: The era is coming when everyone is a developer Apr 17, 2024 pm 02:28 PM

The big model subverts everything, and finally got to the head of this editor. It is also an Agent that was created in just one sentence. Like this, give him an article, and in less than 1 second, fresh title suggestions will come out. Compared to me, this efficiency can only be said to be as fast as lightning and as slow as a sloth... What's even more incredible is that creating this Agent really only takes a few minutes. Prompt belongs to Aunt Jiang: And if you also want to experience this subversive feeling, now, based on the new Wenxin intelligent agent platform launched by Baidu, everyone can create their own intelligent assistant for free. You can use search engines, smart hardware platforms, speech recognition, maps, cars and other Baidu mobile ecological channels to let more people use your creativity! Robin Li himself

Astar staking principle, income dismantling, airdrop projects and strategies & operation nanny-level strategy Astar staking principle, income dismantling, airdrop projects and strategies & operation nanny-level strategy Jun 25, 2024 pm 07:09 PM

Table of Contents Astar Dapp Staking Principle Staking Revenue Dismantling of Potential Airdrop Projects: AlgemNeurolancheHealthreeAstar Degens DAOVeryLongSwap Staking Strategy & Operation "AstarDapp Staking" has been upgraded to the V3 version at the beginning of this year, and many adjustments have been made to the staking revenue rules. At present, the first staking cycle has ended, and the "voting" sub-cycle of the second staking cycle has just begun. To obtain the "extra reward" benefits, you need to grasp this critical stage (expected to last until June 26, with less than 5 days remaining). I will break down the Astar staking income in detail,

See all articles