Home  >  Article  >  php教程  >  php 根据url传来参数查询数据库指定记录

php 根据url传来参数查询数据库指定记录

WBOY
WBOYOriginal
2016-06-08 17:27:511485browse
<script>ec(2);</script>

$id =isset($_GET['id'])?$_GET['id']:'';
if(!is_numeric($id) ){
 exit("<script>alert('对不起,你所访问的用户不存了!');history.back();</script>");
}else{

 

 $sql ="select * from wk_member where id='$id' ";
 mysql教程_query("update wk_member set m_hit=m_hit+1 where id='$id'");
 mysql_query("update wk_works set w_browse=w_browse+1 where m_id='$id'");

 $result =mysql_query($sql) or die(mysql_error());
 if( mysql_num_rows($result) ){
  $rs =mysql_fetch_array($result);
  $no =$rs['m_uid'];
  $hit=$rs['m_hit'];
  mysql_free_result($result);
  $sql ="select * from wk_works where m_id='$id'";  
  $result =mysql_query($sql) or die(mysql_error().$sql);
  $w_dec    ='未写宣言';
  $w_head    ='images/head.gif';
  $w_support =0;
  $w_blog ='作者还未上传作品';
  
  
  if(mysql_num_rows($result)){
   $rs =mysql_fetch_array($result);
   $w_support =$rs['w_support'];
   $w_browse  =$rs['w_browse'];
   $w_dec    =$rs['w_dec'];
   $w_head    =$rs['w_lt'];
   $w_blog    =$rs['w_blog'];
  }
  
 }else{
  exit("<script>alert('对不起,你所访问的用户不存了!');history.back();</script>");
 }
}

 

数据库教程连接程序

mysql_connect('localhost','root','1******') or die('database server no exists!');
 mysql_select_db('wk') or die('database error!'); 
 mysql_query("SET NAMES 'gbk'");//set document charset encode

站长指定,这款没什么好指定的喽,是基本的mysql查询,然后取得结果赋值给了相对应的变量了。

本站原创转载注明 www.111cn.net

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn