php 根据url传来参数查询数据库指定记录
<?php $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查询,然后取得结果赋值给了相对应的变量了。
教程地址:http://www.phprm.com/code/40260cee11e2d987ab9d1ea92dcb1503.html
欢迎转载!但请带上文章地址^^