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 相关文章推荐
PHP4.04简明安装
Oct 09 PHP
实用函数9
Nov 08 PHP
php empty函数判断mysql表单是否为空
Apr 12 PHP
PHP如何抛出异常处理错误
Mar 02 PHP
php curl选项列表(超详细)
Jul 01 PHP
CodeIgniter错误mysql_connect(): No such file or directory解决方法
Sep 06 PHP
js代码实现微博导航栏
Jul 30 PHP
php多线程实现方法及用法实例详解
Oct 26 PHP
php实现当前页面点击下载文件的简单方法
Sep 22 PHP
PHP切割汉字的常用方法实例总结
Apr 27 PHP
Thinkphp5 如何隐藏入口文件index.php(URL重写)
Oct 16 PHP
PHP设计模式(五)适配器模式Adapter实例详解【结构型】
May 02 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 基本语法格式
2009/12/15 PHP
利用PHP生成静态HTML文档的原理
2012/10/29 PHP
php截取视频指定帧为图片
2016/05/16 PHP
php+ajax无刷新上传图片的实现方法
2016/12/06 PHP
无语,javascript居然支持中文(unicode)编程!
2007/04/12 Javascript
javascript+mapbar实现地图定位
2010/04/09 Javascript
jQuery load方法用法集锦
2011/12/06 Javascript
客户端js判断文件类型和文件大小即限制上传大小
2013/11/20 Javascript
jquery form 加载数据示例
2014/04/21 Javascript
调整小数的格式保留小数点后两位
2014/05/14 Javascript
AngularJS入门教程之Hello World!
2014/12/06 Javascript
AngularJS入门教程之学习环境搭建
2014/12/06 Javascript
jQuery Ajax 全局调用封装实例代码详解
2016/06/02 Javascript
基于jQuery实现发送短信验证码后的倒计时功能(无视页面关闭)
2016/09/02 Javascript
js代码实现下拉菜单【推荐】
2016/12/15 Javascript
jquery validation验证表单插件
2017/01/07 Javascript
详解angular2采用自定义指令(Directive)方式加载jquery插件
2017/02/09 Javascript
Vue学习笔记进阶篇之函数化组件解析
2017/07/21 Javascript
原生javascript实现的全屏滚动功能示例
2017/09/19 Javascript
微信小程序后台持续定位功能使用详解
2019/08/23 Javascript
[46:00]Ti4 冒泡赛第二轮LGD vs C9 2
2014/07/14 DOTA
[02:18]《我与DAC》之工作人员:为了热爱DOTA2的玩家们
2018/03/28 DOTA
Python简单调用MySQL存储过程并获得返回值的方法
2015/07/20 Python
python开发之thread线程基础实例入门
2015/11/11 Python
python 爬虫出现403禁止访问错误详解
2017/03/11 Python
基于Python数据可视化利器Matplotlib,绘图入门篇,Pyplot详解
2017/10/13 Python
Tensorflow加载预训练模型和保存模型的实例
2018/07/27 Python
python的dict判断key是否存在的方法
2020/12/09 Python
利用Python过滤相似文本的简单方法示例
2021/02/03 Python
HTML5 Canvas入门学习教程
2016/03/17 HTML / CSS
美国快时尚彩妆品牌:Winky Lux(透明花瓣润唇膏)
2018/11/06 全球购物
环境工程毕业生自荐信
2013/11/17 职场文书
2015年外贸业务员工作总结范文
2015/05/23 职场文书
党小组推荐意见
2015/06/02 职场文书
JavaScript+HTML实现学生信息管理系统
2021/04/20 Javascript
生命的关键成分来自太空?陨石说是的
2022/04/29 数码科技