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
PHP按行读取、处理较大CSV文件的代码实例
Apr 09 PHP
PHP列出MySQL中所有数据库的方法
Mar 12 PHP
php从给定url获取文件扩展名的方法
Mar 14 PHP
浅谈PHP接收POST数据方式
Jun 05 PHP
PHP使用curl模拟post上传及接收文件的方法
Mar 04 PHP
一个简单的php MVC留言本实例代码(必看篇)
Sep 22 PHP
PHP 实现文件压缩解压操作的方法
Jun 14 PHP
浅谈laravel-admin form中的数据,在提交后,保存前,获取并进行编辑
Oct 21 PHP
php装饰者模式简单应用案例分析
Oct 23 PHP
如何在PHP中使用数组
Jun 09 PHP
Laravel6.18.19如何优雅的切换发件账户
Jun 14 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的FTP学习(二)
2006/10/09 PHP
Apache, PHP在Windows 9x/NT下的安装与配置 (二)
2006/10/09 PHP
第四节--构造函数和析构函数
2006/11/16 PHP
php 防止单引号,双引号在接受页面转义
2008/07/10 PHP
探讨fckeditor在Php中的配置详解
2013/06/08 PHP
php setcookie(name, value, expires, path, domain, secure) 参数详解
2013/06/28 PHP
解析在PHP中使用mysqli扩展库对mysql的操作
2013/07/03 PHP
php为字符串前后添加指定数量字符的方法
2015/05/04 PHP
分享5个非常有用的Laravel Blade指令
2018/05/30 PHP
jquery.validate使用攻略 第三部
2010/07/01 Javascript
javascript实现简单的Map示例介绍
2013/12/23 Javascript
Nodejs+express+html5 实现拖拽上传
2014/08/08 NodeJs
浅谈Javascript中深复制
2014/12/01 Javascript
javascript中AJAX用法实例分析
2015/01/30 Javascript
Bootstrap编写一个在当前网页弹出可关闭的对话框 非弹窗
2016/06/30 Javascript
微信小程序 wxapp画布 canvas详细介绍
2016/10/31 Javascript
Angular的事件和表单详解
2016/12/26 Javascript
微信小程序使用车牌号输入法的示例代码
2019/08/20 Javascript
JavaScript JSON使用原理及注意事项
2020/07/30 Javascript
解决vue+webpack项目接口跨域出现的问题
2020/08/10 Javascript
跟老齐学Python之集成开发环境(IDE)
2014/09/12 Python
Python实现字典的key和values的交换
2015/08/04 Python
python 实时得到cpu和内存的使用情况方法
2018/06/11 Python
Python推导式简单示例【列表推导式、字典推导式与集合推导式】
2018/12/04 Python
Django 如何使用日期时间选择器规范用户的时间输入示例代码详解
2020/05/22 Python
python 可视化库PyG2Plot的使用
2021/01/21 Python
Pycharm 如何一键加引号的方法步骤
2021/02/05 Python
澳大利亚百货公司:David Jones
2018/02/08 全球购物
澳大利亚最大的在线美发和美容零售商之一:My Hair Care & Beauty
2019/08/24 全球购物
公关关系专员的自我评价分享
2013/11/20 职场文书
工程业务员工作职责
2013/12/07 职场文书
同学会邀请书大全
2014/01/12 职场文书
时尚休闲吧创业计划书
2014/01/25 职场文书
安装pytorch时报sslerror错误的解决方案
2021/05/17 Python
详解php中流行的rpc框架
2021/05/29 PHP
Win11筛选键导致键盘失灵怎么解决? Win11关闭筛选键的技巧
2022/04/08 数码科技