Home Web Front-end JS Tutorial A complete list of commonly used PHP and SQL statements

A complete list of commonly used PHP and SQL statements

Dec 22, 2016 pm 02:09 PM
php sql statement

This article introduces you to the commonly used PHP and SQL statements. The specific codes are as follows:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

<?php

$conn=mysql_connect("localhost","root","root");

mysql_select_db("db_database17",$conn);

mysql_query("set names gb2312");

?>

<?php

$sql1=mysql_query("select usernc,face,ip,email,qq from tb_user where id=&#39;".$info["userid"]."&#39;",$conn);

$info1=mysql_fetch_array($sql1);

echo $info1["face"];

?>

action="savereg.php"

<input type="text" name="usernc"

<input type="text" name="userpwd"

<input type="text" name="truename"

<?php

if(mysql_query("insert into tb_user(usernc,userpwd,truename,email,qq,tel,ip,address,face,regtime,sex,usertype) values(&#39;".$usernc."&#39;,&#39;".md5(trim($_POST["userpwd"]))."&#39;,&#39;".$_POST["truename"]."&#39;,&#39;".$_POST["email"]."&#39;,&#39;".$_POST["qq"]."&#39;,&#39;".$_POST["tel"]."&#39;,&#39;".$ip."&#39;,&#39;".$_POST["address"]."&#39;,&#39;".$_POST["face"]."&#39;,&#39;".date("Y-m-d H:i:s")."&#39;,&#39;".$_POST["sex"]."&#39;,&#39;0&#39;)",$conn)){

if($_SESSION["unc"]!=""){

  session_unregister("unc");

  }

session_register("unc");

  $_SESSION["unc"]=$usernc;

  echo "<script>alert(&#39;注册成功!&#39;);history.back();</script>";

}else{

  echo "<script>alert(&#39;注册失败!&#39;);history.back();</script>";

}

?>

<?php

  $sql=mysql_query("select count(*) as total from tb_leaveword ",$conn);//把查询的结果存入total中

  $info=mysql_fetch_array($sql);

  $total=$info[total];

  if($total==0){

   echo "<div align=center>对不起,暂无留言!</div>";

  }else{

   if(!isset($_GET["page"]) || !is_numeric($_GET["page"])){

     $page=1;

   }else{

     $page=intval($_GET["page"]);

   }

   $pagesize=3;

   if($total%$pagesize==0){

     $pagecount=intval($total/$pagesize);

   }else{

     $pagecount=ceil($total/$pagesize);

   }

   $sql=mysql_query("select * from tb_leaveword order by createtime desc limit ".($page-1)*$pagesize.",$pagesize ",$conn);

   while($info=mysql_fetch_array($sql)){

   ?>

<table width="520" height="5" border="0" align="center" cellpadding="0" cellspacing="0">

   <tr>

    <td></td>

   </tr>

  </table>

   <table width="550" height="155" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FCD424">

    <tr>

     <td bgcolor="#FFFFFF" valign="top"><table width="550" height="24" border="0" align="center" cellpadding="0" cellspacing="0">

      <tr>

       <td width="450" background="images/dh_back_1.gif"> 主  题:<?php echo unhtml($info["title"]);?></td>

       <td width="100" background="images/dh_back_1.gif"><div align="center">

   <script language="javascript">

    function openeditwindow(x){

    window.open("editleaveword.php?id="+x,"newframe","top=100,left=200,width=450,height=280,menubar=no,location=no,scrollbars=no,status=no");

   }

   </script>

  <?php

   $sqlu=mysql_query("select usernc from tb_user where id=&#39;".$info["userid"]."&#39;",$conn);

   $infou=mysql_fetch_array($sqlu);

   if($infou["usernc"]==$_SESSION["unc"]){

  ?>

    <a href="javascript:openeditwindow(<?php echo $info[id];?>)" class="a1">编辑</a>

  <?php

   }

  ?>

     

  <?php

   if($_SESSION["unc"]!=""){

   $sqld=mysql_query("select usertype from tb_user where usernc=&#39;".$_SESSION["unc"]."&#39;",$conn);

        $infod=mysql_fetch_array($sqld);

   if($infod["usertype"]==1){

   ?>

   <a href="javascript:if(window.confirm(&#39;确定删除该留言信息么?&#39;)==true){window.location.href=&#39;deleteleaveword.php?id=<?php echo $info[id];?>&#39;;}" class="a1">删除</a>

  <?php

   }

   }

  ?>

   </div></td>

      </tr>

     </table>

      <table width="550" height="5" border="0" align="center" cellpadding="0" cellspacing="0">

       <tr>

        <td></td>

       </tr>

      </table>

  <table width="550" height="120" border="0" align="center" cellpadding="0" cellspacing="0">

       <tr>

        <td width="150" height="90"><div align="center"><img src="<?php

   $sql1=mysql_query("select usernc,face,ip,email,qq from tb_user where id=&#39;".$info["userid"]."&#39;",$conn);

   $info1=mysql_fetch_array($sql1);

   echo $info1["face"];

   ?>" /><br><?php echo $info1["usernc"];?></div></td>

        <td width="10" background="images/line_down.gif"></td>

        <td width="390" rowspan="2"><?php echo unhtml($info["content"]);?></td>

       </tr>

       <tr>

        <td height="30"><div align="center"><img src="images/email.gif" width="45" height="16" alt="<?php echo $info1[email];?>"/><img src="images/ip.gif" width="55" height="16" alt="<?php echo $info1[ip];?>"/><img src="images/qq.gif" width="45" height="16" alt="<?php echo $info1[qq];?>"/></div></td>

        <td width="10" background="images/line_down.gif"></td>

       </tr>

      </table>

  </td>

    </tr>

   </table>

  <?php

  }

  }

  ?>

    

  <table width="550" height="25" border="0" align="center" cellpadding="0" cellspacing="0">

     <tr>

      <td width="351"><div align="left">共有留言 <?php echo $total;?> 条 每页显示 <?php echo $pagesize;?> 条 第 <?php echo $page;?> 页/共 <?php echo $pagecount;?> 页</div></td>

      <td width="199"><div align="right"><a href="<?php echo $_SERVER["PHP_SELF"]?>?page=1" class="a1">首页</a> <a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php

  if($page>1)

   echo $page-1;

  else

   echo 1;

   ?>" class="a1">上一页</a> <a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php

  if($page<$pagecount)

   echo $page+1;

  else

   echo $pagecount;

   ?>

Copy after login


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)

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

The Future of PHP: Adaptations and Innovations The Future of PHP: Adaptations and Innovations Apr 11, 2025 am 12:01 AM

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

How to create tables with sql server using sql statement How to create tables with sql server using sql statement Apr 09, 2025 pm 03:48 PM

How to create tables using SQL statements in SQL Server: Open SQL Server Management Studio and connect to the database server. Select the database to create the table. Enter the CREATE TABLE statement to specify the table name, column name, data type, and constraints. Click the Execute button to create the table.

PHP's Current Status: A Look at Web Development Trends PHP's Current Status: A Look at Web Development Trends Apr 13, 2025 am 12:20 AM

PHP remains important in modern web development, especially in content management and e-commerce platforms. 1) PHP has a rich ecosystem and strong framework support, such as Laravel and Symfony. 2) Performance optimization can be achieved through OPcache and Nginx. 3) PHP8.0 introduces JIT compiler to improve performance. 4) Cloud-native applications are deployed through Docker and Kubernetes to improve flexibility and scalability.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

How to judge SQL injection How to judge SQL injection Apr 09, 2025 pm 04:18 PM

Methods to judge SQL injection include: detecting suspicious input, viewing original SQL statements, using detection tools, viewing database logs, and performing penetration testing. After the injection is detected, take measures to patch vulnerabilities, verify patches, monitor regularly, and improve developer awareness.

See all articles