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 相关文章推荐
图形数字验证代码
Oct 09 PHP
数字转英文
Dec 06 PHP
PHP中source #N问题的解决方法
Jan 27 PHP
php中magic_quotes_gpc对unserialize的影响分析
Dec 16 PHP
深入php内核之php in array
Nov 10 PHP
简单的php+mysql聊天室实现方法(附源码)
Jan 05 PHP
详谈PHP程序Laravel 5框架的优化技巧
Jul 18 PHP
PHP用FTP类上传文件视频等的简单实现方法
Sep 23 PHP
一键生成各种尺寸Icon的php脚本(实例)
Feb 08 PHP
php获取ip及网址的简单方法(必看)
Apr 01 PHP
详解Laravel5.6 Passport实现Api接口认证
Jul 27 PHP
Laravel框架控制器的middleware中间件用法分析
Sep 30 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实现的获取URL信息的类
2007/01/02 PHP
php根据分类合并数组的方法实例详解
2013/11/06 PHP
php文件压缩之PHPZip类用法实例
2015/06/18 PHP
PHP中filter函数校验数据的方法详解
2015/07/31 PHP
Zend Framework教程之请求对象的封装Zend_Controller_Request实例详解
2016/03/07 PHP
smarty的section嵌套循环用法示例
2016/05/28 PHP
几个常用的JavaScript字符串处理函数 - split()、join()、substring()和indexOf()
2009/06/02 Javascript
通过Javascript将数据导出到外部Excel文档的函数代码
2012/06/15 Javascript
基于jquery的滚动条滚动固定div(附演示下载)
2012/10/29 Javascript
jquery事件重复绑定的快速解决方法
2014/01/03 Javascript
用jquery模仿的a的title属性的例子
2014/10/22 Javascript
jQuery检测输入的字符串包含的中英文的数量
2015/04/17 Javascript
[原创]Javascript 实现广告后加载 可加载百度谷歌联盟广告
2016/05/11 Javascript
node.js express安装及示例网站搭建方法(分享)
2016/08/22 Javascript
jQuery通过ajax方法获取json数据不执行success的原因及解决方法
2016/10/15 Javascript
微信小程序-图片、录音、音频播放、音乐播放、视频、文件代码实例
2016/11/22 Javascript
基于JavaScript定位当前的地理位置
2017/04/11 Javascript
mpvue写一个CPASS小程序的示例
2018/09/04 Javascript
Python中类的继承代码实例
2014/10/28 Python
python机器学习实战之最近邻kNN分类器
2017/12/20 Python
python使用 zip 同时迭代多个序列示例
2019/07/06 Python
Django为窗体加上防机器人的验证码功能过程解析
2019/08/14 Python
Python实现TCP探测目标服务路由轨迹的原理与方法详解
2019/09/04 Python
pytorch对梯度进行可视化进行梯度检查教程
2020/02/04 Python
Python如何读取、写入JSON数据
2020/07/28 Python
python中函数返回多个结果的实例方法
2020/12/16 Python
手把手教你用纯css3实现轮播图效果实例
2017/05/04 HTML / CSS
CSS3 清除浮动的方法示例
2018/06/01 HTML / CSS
HTML5 weui使用笔记
2019/11/21 HTML / CSS
六一儿童节致辞
2015/07/31 职场文书
党校培训学习心得体会
2016/01/06 职场文书
课改心得体会范文
2016/01/25 职场文书
pytorch实现ResNet结构的实例代码
2021/05/17 Python
Matlab如何实现矩阵复制扩充
2021/06/02 Python
python基础之文件操作
2021/10/24 Python
SSM项目使用拦截器实现登录验证功能
2022/01/22 Java/Android