【php实现的MySQL通用查询程序】教程文章相关的互联网学习教程文章

php获取谷歌PR值算法与php查询PR值的代码

<?php/* *功能:对URL进行编码 *参数说明:$web_url 网站URL,不包含"http://",例如jbxue.com*/ function HashURL($url){ $SEED = "Mining PageRank is AGAINST GOOGLES TERMS OF SERVICE. Yes, Im talking to you, scammer."; $Result = 0x01020345; for ($i=0; $i<strlen($url); $i++) { $Result ^= ord($SEED{$i%87}) ^ ord($url{$i}); $Result = (($Result >> 23) & 0x1FF) | $Result << 9; } return sprintf("8%x", $Result); }...

在线查询GooglePR值的PHP代码

/*** 获取Google PR值* by bbs.it-home.org*/define('GOOGLE_MAGIC', 0xE6359A60); function zeroFill($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a>>1); $a &= (~$z); $a |= 0x40000000; $a = ($a>>($b-1)); } else { $a = ($a>>$b); } return $a; }function mix($a,$b,$c) { $a -= $b; $a -= $c; $a ^= (zeroFill($c,13)); $b -= $c; $b -= $a; $b ^= ($a$c -= $a; $c -= $b; $c ^= (zeroFill($b,13)); $a -= $b; ...

phphttp_build_query()构建查询参数的小例子

/*** http_build_query() 构建查询参数* edit: bbs.it-home.org*/$vars = array('page' => 4, 'search' => 'this & that');$qs = http_build_query($vars);$url = 'http://bbs.it-home.org/search.php?' . $qs;$page = file_get_contents($url);?>

php快递查询API类(支持各种快递的查询)

本文介绍下,用php实现的查询快递信息的一个api类,可以支持多种快递。有需要的朋友参考下。以下是一个封装好的快递查询类,分享给大家。 代码如下:expressname = $this->expressname();}/** 采集网页内容的方法*/private function getcontent($url){if(function_exists("file_get_contents")){$file_contents = file_get_contents($url);}else{$ch = curl_init();$timeout = 5;curl_setopt($ch, CURLOPT_URL, $url);curl_setopt ...

php查询百度与google收录情况的实现代码

本文介绍下,用php实现的查询百度收录、谷歌收录情况的一段代码,有需要的朋友参考下。用php来查询百度或google的收录情况,其实并不复杂,只需要file下远程文件,然后分析相关数据即可。 以下是收录查询核心代码,getdetail函数也可以这样写,用正则去匹配:$wordf = preg_quote($wordf); $wordb = preg_quote($wordb); $pagecontent = @preg_replace("/\s*$wordf(.+?)$wordb\s*/e", "returndetail(\\1, $type)", $pagecontent); ...

php实现dns域名查询的方法详解(图文)【图】

本文介绍下,用php实现的一段查询dns域名信息的代码,有需要的朋友参考下。在php中与域名相关的操作,一般会用到二个函数,它们分别是:gethostbyname() 与gethostbyaddr()。 一,IP地址查询 gethostbyname()函数,可以用来查找一个给定的域名的IP地址。 gethostbyname()返回对应于给定主机名的包含主机名字和地址信息的hostent结构指针。 string gethostbyname(string hostname) 参数:主机名,不需要http://,例如:bbs.it-hom...

PHPwhois客户端查询的实现代码

/*** whois信息查询* by bbs.it-home.org*/function ae_whois($query, $server){ define('AE_WHOIS_TIMEOUT', 15); // connection timeout global $ae_whois_errno, $ae_whois_errstr; // connecting $f = fsockopen($server, 43, $ae_whois_errno, $ae_whois_errstr, AE_WHOIS_TIMEOUT); if (!$f) return false; // connection failed // sending query fwrite($f, $query."\r\n"); // rece...

php查询字符串传值(字符串值、数字值)的例子

本文介绍下,php在查询字符串中传递值的方法,举了二个例子,分别用来传递字符串值、数字值。有需要的朋友,参考下吧。例1,在查询字符串中传递字符串值Click a link to move to a new page:Content 1Content 2Content 3很抱歉,您请求的页面不存在。";}}?>例2,在查询字符串中传递数值查询字符串传递数值-bbs.it-home.orgClick a link to change the text color of the verbiage below:GreenRedBlue重置信息; font-weight: bold;"...

php进行mysql参数化查询的例子

本文介绍下,在php中,进行mysql参数化查询的一个例子,有需要的朋友参考下。分享下,php mysql参数化查询的例子。 代码:prepare("SELECT priv FROM testUsers WHERE username=? AND password=?"); $stmt -> bind_param("ss", $user, $pass); $stmt -> execute(); ?>

php数据库连接、查询、显示结果的小例子

/*** php操作数据库(连接、查询、显示结果)* edit: bbs.it-home.org*/define ('HOSTNAME', 'localhost'); //数据库主机名define ('USERNAME', 'username'); //数据库用户名define ('PASSWORD', 'password'); //数据库用户登录密码define ('DATABASE_NAME', 'testdb'); //需要查询的数据库$db = mysql_connect(HOSTNAME, USERNAME, PASSWORD) or die (mysql_error());//连接不上,就会显示mysql出错的原因。mysql_select_db...

PHP日期查询函数实用代码

date_default_timezone_set('PRC'); //默认时区 echo "今天:",date("Y-m-d",time()),""; echo "今天:",date("Y-m-d",strtotime("18 june 2008")),""; echo "昨天:",date("Y-m-d",strtotime("-1 day")), ""; echo "明天:",date("Y-m-d",strtotime("+1 day")), ""; echo "一周后:",date("Y-m-d",strtotime("+1 week")), ""; echo "一周零两天四小时两秒后:",date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds")), "";...

php+mysql分页查询代码(mysql分页示例)

/** php分页查询代码* */$perpagenum = 10;//定义每页显示几条 $total = mysql_fetch_array(mysql_query("select count(*) from a"));//查询数据库中一共有多少条数据 $Total = $total[0]; // $Totalpage = ceil($Total/$perpagenum);//上舍,取整 if(!isset($_GET['page'])||!intval($_GET['page'])||$_GET['page']>$Totalpage)//page可能的四种状态 { $page=1; } else {...

php+mysql分页查询代码与演示例子【图】

//为了避免重复包含文件而造成错误,加了判断函数是否存在的条件:if(!function_exists(pages)){ //定义函数pages(),三个参数的含义为://$total:信息总数;//$displaypg:每页显示信息数,这里设置为默认是20;//$url:分页导航中的链接,除了加入不同的查询信息&ldquo;page&rdquo;外的部分都与这个URL相同。//默认值本该设为本页URL(即$_SERVER["REQUEST_URI"]),但设置默认值的右边只能为常量,所以该默认值设为空字符串,在...

php+mysql数据库查询分页代码示例

/** php+mysql分页代码* */$SQL_TABL="abc"; //表名$where_name="id > 10";//查询条件$perpagenum = 3; //每页显示数量$total = mysql_fetch_array(mysql_query("select count(*) AS count from $SQL_TABL WHERE (".@$where_name.")"));$sql_count=$total['count']; //获取返回的数据条数unset($total); //注销变量 $total//计算出不准确的页面数$page_all_num_f为整数,$page_all_num_t为准确值(可能为小数)$page_all_num_f=rou...

php+mysql分页查询代码原理解析

$pagesize=10; //设置每一页显示的记录数$conn=mysql_connect("localhost","root",""); //连接数据库$rs=mysql_query("select count(*) from tb_product",$conn); //取得记录总数$rs$myrow = mysql_fetch_array($rs);$numrows=$myrow[0];//计算总页数$pages=intval($numrows/$pagesize);//判断页数设置if (isset($_GET[page])){ $page=intval($_GET[page]);}else{  $page=1; //否则,设置为第一页}三、创建用例用表myTablephp分页...