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自动生成月历代码
Oct 09 PHP
php代码优化及php相关问题总结
Oct 09 PHP
php读取数据库信息的几种方法
May 24 PHP
php生成随机数或者字符串的代码
Sep 05 PHP
php长字符串定义方法
Jul 12 PHP
关于svn冲突的解决方法
Jun 21 PHP
分割GBK中文遭遇乱码的解决方法
Aug 09 PHP
PHP网页游戏学习之Xnova(ogame)源码解读(十三)
Jun 26 PHP
php保存信息到当前Session的方法
Mar 16 PHP
PHP bin2hex()函数基础实例讲解
Feb 11 PHP
PHP发送邮件确认验证注册功能示例【修改别人邮件类】
Nov 09 PHP
使用Rancher在K8S上部署高性能PHP应用程序的教程
Jul 10 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递归函数返回值使用方法
2013/02/18 PHP
CI框架学习笔记(一) - 环境安装、基本术语和框架流程
2014/10/26 PHP
PHP抓取淘宝商品的用户晒单评论+图片+搜索商品列表实例
2016/04/14 PHP
mac系统下为 php 添加 pcntl 扩展
2016/08/28 PHP
php实现压缩合并js的方法【附demo源码下载】
2016/09/22 PHP
PHP中localeconv()函数的用法
2019/03/26 PHP
jQuery源码分析-03构造jQuery对象-源码结构和核心函数
2011/11/14 Javascript
jQuery固定元素插件scrolltofixed使用指南
2015/04/21 Javascript
jquery插件validation实现验证身份证号等
2015/06/04 Javascript
js实现跨域的几种方法汇总(图片ping、JSONP和CORS)
2015/10/25 Javascript
js console.log打印对像与数组用法详解
2016/01/21 Javascript
微信小程序 常见问题总结(4058,40013)及解决办法
2017/01/11 Javascript
jQuery实现获取隐藏div高度的方法示例
2017/02/09 Javascript
ajax +NodeJS 实现图片上传实例
2017/06/06 NodeJs
基于jQuery对象和DOM对象和字符串之间的转化实例
2017/08/08 jQuery
layui select动态添加option的实例
2018/03/07 Javascript
vue地区选择组件教程详解
2018/05/04 Javascript
layer弹出框确定前验证:弹出消息框的方法(弹出两个layer)
2019/09/21 Javascript
js实现页面导航层级指示效果
2020/08/25 Javascript
html+vue.js 实现漂亮分页功能可兼容IE
2020/11/07 Javascript
[42:22]DOTA2上海特级锦标赛C组小组赛#1 OG VS Archon第一局
2016/02/27 DOTA
Python中的集合类型知识讲解
2015/08/19 Python
Python中关键字nonlocal和global的声明与解析
2017/03/12 Python
python中MethodType方法介绍与使用示例
2017/08/03 Python
python多任务之协程的使用详解
2019/08/26 Python
Python 异步协程函数原理及实例详解
2019/11/13 Python
python随机模块random使用方法详解
2020/02/14 Python
HTML5实现视频弹幕功能
2019/08/09 HTML / CSS
ziaja齐叶雅官方海外旗舰店:来自波兰的天然护肤品牌
2017/01/02 全球购物
巴西宠物商店:Cobasi
2019/04/19 全球购物
JSF面试题:Jsf中的核心类用那些?有什么作用?LiftCycle六大生命周期是什么?
2014/07/17 面试题
幼儿园教师培训方案
2014/02/04 职场文书
在校大学生个人的自我评价
2014/02/13 职场文书
2015年五四青年节演讲稿
2015/03/18 职场文书
Linux系统下安装PHP7.3版本
2021/06/26 PHP
MySQL分区表管理命令汇总
2022/03/21 MySQL