首页 web前端 js教程 PHP与SQL语句常用大全

PHP与SQL语句常用大全

Dec 22, 2016 pm 02:09 PM
php sql语句

本文给大家介绍PHP与SQL语句常用大全,具体代码如下所述:

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;

   ?>

登录后复制


本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

PHP和Python:比较两种流行的编程语言 PHP和Python:比较两种流行的编程语言 Apr 14, 2025 am 12:13 AM

PHP和Python各有优势,选择依据项目需求。1.PHP适合web开发,尤其快速开发和维护网站。2.Python适用于数据科学、机器学习和人工智能,语法简洁,适合初学者。

PHP:网络开发的关键语言 PHP:网络开发的关键语言 Apr 13, 2025 am 12:08 AM

PHP是一种广泛应用于服务器端的脚本语言,特别适合web开发。1.PHP可以嵌入HTML,处理HTTP请求和响应,支持多种数据库。2.PHP用于生成动态网页内容,处理表单数据,访问数据库等,具有强大的社区支持和开源资源。3.PHP是解释型语言,执行过程包括词法分析、语法分析、编译和执行。4.PHP可以与MySQL结合用于用户注册系统等高级应用。5.调试PHP时,可使用error_reporting()和var_dump()等函数。6.优化PHP代码可通过缓存机制、优化数据库查询和使用内置函数。7

PHP的未来:改编和创新 PHP的未来:改编和创新 Apr 11, 2025 am 12:01 AM

PHP的未来将通过适应新技术趋势和引入创新特性来实现:1)适应云计算、容器化和微服务架构,支持Docker和Kubernetes;2)引入JIT编译器和枚举类型,提升性能和数据处理效率;3)持续优化性能和推广最佳实践。

PHP与Python:了解差异 PHP与Python:了解差异 Apr 11, 2025 am 12:15 AM

PHP和Python各有优势,选择应基于项目需求。1.PHP适合web开发,语法简单,执行效率高。2.Python适用于数据科学和机器学习,语法简洁,库丰富。

sql server怎么用sql语句创建表 sql server怎么用sql语句创建表 Apr 09, 2025 pm 03:48 PM

在 SQL Server 中使用 SQL 语句创建表的方法:打开 SQL Server Management Studio 并连接到数据库服务器。选择要创建表的数据库。输入 CREATE TABLE 语句,指定表名、列名、数据类型和约束。单击执行按钮创建表。

PHP行动:现实世界中的示例和应用程序 PHP行动:现实世界中的示例和应用程序 Apr 14, 2025 am 12:19 AM

PHP在电子商务、内容管理系统和API开发中广泛应用。1)电子商务:用于购物车功能和支付处理。2)内容管理系统:用于动态内容生成和用户管理。3)API开发:用于RESTfulAPI开发和API安全性。通过性能优化和最佳实践,PHP应用的效率和可维护性得以提升。

PHP的当前状态:查看网络开发趋势 PHP的当前状态:查看网络开发趋势 Apr 13, 2025 am 12:20 AM

PHP在现代Web开发中仍然重要,尤其在内容管理和电子商务平台。1)PHP拥有丰富的生态系统和强大框架支持,如Laravel和Symfony。2)性能优化可通过OPcache和Nginx实现。3)PHP8.0引入JIT编译器,提升性能。4)云原生应用通过Docker和Kubernetes部署,提高灵活性和可扩展性。

PHP的目的:构建动态网站 PHP的目的:构建动态网站 Apr 15, 2025 am 12:18 AM

PHP用于构建动态网站,其核心功能包括:1.生成动态内容,通过与数据库对接实时生成网页;2.处理用户交互和表单提交,验证输入并响应操作;3.管理会话和用户认证,提供个性化体验;4.优化性能和遵循最佳实践,提升网站效率和安全性。

See all articles