PHP与SQL语句常用大全


Posted in PHP onDecember 10, 2016

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

<?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='".$info["userid"]."'",$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('".$usernc."','".md5(trim($_POST["userpwd"]))."','".$_POST["truename"]."','".$_POST["email"]."','".$_POST["qq"]."','".$_POST["tel"]."','".$ip."','".$_POST["address"]."','".$_POST["face"]."','".date("Y-m-d H:i:s")."','".$_POST["sex"]."','0')",$conn)){
if($_SESSION["unc"]!=""){
  session_unregister("unc");
  }
session_register("unc");
  $_SESSION["unc"]=$usernc;  
  echo "<script>alert('注册成功!');history.back();</script>";
}else{
  echo "<script>alert('注册失败!');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='".$info["userid"]."'",$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='".$_SESSION["unc"]."'",$conn);
        $infod=mysql_fetch_array($sqld);
   if($infod["usertype"]==1){ 
   ?>
   <a href="javascript:if(window.confirm('确定删除该留言信息么?')==true){window.location.href='deleteleaveword.php?id=<?php echo $info[id];?>';}" 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='".$info["userid"]."'",$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; 
   ?>

以上所述是小编给大家介绍的PHP与SQL语句常用大全,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的,在此也非常感谢大家对三水点靠木网站的支持!

PHP 相关文章推荐
PHP 和 MySQL 基础教程(三)
Oct 09 PHP
一个简洁的多级别论坛
Oct 09 PHP
PHP删除目录及目录下所有文件的方法详解
Jun 06 PHP
php 注册时输入信息验证器的实现详解
Jul 05 PHP
PHP中获取时间的下一周下个月的方法
Mar 18 PHP
PHP、Java des加密解密实例
Apr 27 PHP
Cygwin中安装PHP方法步骤
Jul 04 PHP
PHP开发中AJAX技术的简单应用
Dec 11 PHP
Yii2 中实现单点登录的方法
Mar 09 PHP
Yii框架实现对数据库的CURD操作示例
Sep 03 PHP
PHP超全局变量实现原理及代码解析
Sep 01 PHP
PHP中->和=>的意思
Mar 31 PHP
PHP中SQL查询语句的id=%d解释(推荐)
Dec 10 #PHP
PHP获取页面执行时间的方法(推荐)
Dec 10 #PHP
PHP页面跳转实现延时跳转的方法
Dec 10 #PHP
php异步:在php中使用fsockopen curl实现类似异步处理的功能方法
Dec 10 #PHP
浅谈php中curl、fsockopen的应用
Dec 10 #PHP
Zend Framework动作控制器用法示例
Dec 09 #PHP
Zend Framework入门教程之Zend_View组件用法示例
Dec 09 #PHP
You might like
用PHP调用数据库的存贮过程
2006/10/09 PHP
ThinkPHP使用getlist方法实现数据搜索功能示例
2017/05/08 PHP
PHP文字转图片功能原理与实现方法分析
2017/08/31 PHP
php ActiveMQ的安装与使用方法图文教程
2020/02/23 PHP
Jquery+WebService 校验账号是否已被注册的代码
2010/07/12 Javascript
分享Javascript中最常用的55个经典小技巧
2013/11/29 Javascript
浏览器兼容性问题大汇总
2015/12/17 Javascript
基于jquery实现智能表单验证操作
2016/05/09 Javascript
jQueryUI DatePicker 添加时分秒
2016/06/04 Javascript
微信小程序 基础组件与导航组件详细介绍
2017/02/21 Javascript
详解node child_process模块学习笔记
2018/01/24 Javascript
如何在vue中使用ts的示例代码
2018/02/28 Javascript
javascript将非数值转换为数值
2018/09/13 Javascript
vue使用v-for实现hover点击效果
2018/09/29 Javascript
微信小程序在其他页面监听globalData中值的变化
2019/07/15 Javascript
JavaScript ES6 Class类实现原理详解
2020/05/08 Javascript
[11:42]2018DOTA2国际邀请赛寻真——OG卷土重来
2018/08/17 DOTA
python网络编程学习笔记(九):数据库客户端 DB-API
2014/06/09 Python
Python递归函数定义与用法示例
2017/06/02 Python
Python序列循环移位的3种方法推荐
2018/04/09 Python
对Python中type打开文件的方式介绍
2018/04/28 Python
python列表list保留顺序去重的实例
2018/12/14 Python
python+openCV调用摄像头拍摄和处理图片的实现
2019/08/06 Python
Python Tkinter模块 GUI 可视化实例
2019/11/20 Python
Pycharm 2020年最新激活码(亲测有效)
2020/09/18 Python
预订旅游活动、景点和旅游:GetYourGuide
2019/09/29 全球购物
请用Java实现列出某个目录下的所有文件
2013/09/23 面试题
大三学生入党思想汇报
2014/01/02 职场文书
驾驶员岗位职责
2014/01/29 职场文书
《逃家小兔》教学反思
2014/02/23 职场文书
李培根演讲稿
2014/05/22 职场文书
2014年商场工作总结
2014/11/22 职场文书
2015年安全员工作总结范文
2015/04/22 职场文书
检讨书范文大全
2015/05/07 职场文书
治理商业贿赂工作总结
2015/08/10 职场文书
Java SSH 秘钥连接mysql数据库的方法
2021/06/28 Java/Android