Additions and deletions of phpstudy7--mysql database

Source: Internet
Author: User

1. Add Data:

1     //Add Data2 3     $strsql= "INSERT into User_info (userid,username,phonenumber,userscore,datatime) VALUES (null, '$name‘,‘$phone‘,‘$score', Now ()) ";4     $result= @mysql_query($strsql);5     6     //successfully added7     if($result)8     {9         Echo true;Ten}Else{ One         Echo false; A}

2. Delete data:

3. Database Query Sample code:

1     //querying user data and returning user array objects2     $STRSQL= "SELECT * from User_info";//SQL query Statements3     mysql_query("SET NAMES UTF8");4     $result=mysql_query($STRSQL);//Get Data Set5     6     $users;$user;$i=0;7      while($row=Mysql_fetch_array($result))8     {9         $user["UserId"]=$row["UserId"];Ten         $user["UserName"]=$row["UserName"]; One         $user["PhoneNumber"]=$row["PhoneNumber"]; A         $user["Userscore"]=$row["Userscore"]; -         $user["Datatime"]=$row["Datatime"]; -         $users[$i++]=$user; the     } -     //echo $strSql; -     Echo UrlDecode(Json_encode ($users));
    // Count query, returns the number of    data bars $STRSQL // SQL query Statements    mysql_query ("SET NAMES UTF8");     $result mysql_query ($strSql// get data set    $row=mysql_fetch_array($result);     Echo $row [0];

4. Modify the data:

//Update Data$query= "Update question set question="$question', answer1= '$answer 1', answer2= '$answer 2', answer3= '$answer 3', answer4= '$answer 4', result=$resultwhere id=$id";$rs=mysql_query($query);//Execute Queryif($rs){    Echo true;}Else{    Echo false;}

Additions and deletions of phpstudy7--mysql database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.