当前位置: 编程技术>php
本页文章导读:
▪一个模仿oso的php论坛程序(之一)第1/2页
我经常使用oso的论坛,个人感觉挺好的,因此模仿oso的界面编了一个程序,与大家共享。 程序由三部分组成,即显示主题信息,显示论坛信息,增加论坛信息,主题与论坛内容采用主从表.........
▪一个简单的php实现的MySQL数据浏览器
这个程序可以用来浏览MySQL中的数据,您可以稍做修改就可以做出很不错的MySQL浏览器. */ /* ?cmd=db ?cmd=table&db={} ?cmd=record&db={}&table={} */ $host = 'localhost'; $user = 'test'; $password = ''; if(!i.........
▪php实现的MySQL通用查询程序
if(get_magic_quotes_gpc()==1){ ?> <html> <head><title>MySQL通用查询程序</title></head> <body> 注意本程序需要将PHP配置文件(PHP3为php3.ini,PHP4为php.ini)中的magic_quotes_gpc 设成Off.........
[1]一个模仿oso的php论坛程序(之一)第1/2页
来源: 互联网 发布时间: 2013-11-30
我经常使用oso的论坛,个人感觉挺好的,因此模仿oso的界面编了一个程序,与大家共享。
程序由三部分组成,即显示主题信息,显示论坛信息,增加论坛信息,主题与论坛内容采用主从表关系。
表结构如下:
drop table fr_t_forumtitle;
create table fr_t_forumtitle(
id integer,
state varchar(1),
readcount integer,
replycount integer,
title varchar(100),
createman varchar(20),
replyman varchar(20),
replytime datetime);
drop table fr_t_forumcontent;
create table fr_t_forumcontent(
id integer,
replyman varchar(20),
replytime datetime,
replyemail varchar(100),
replyhttp varchar(100),
replyface smallint,
content text);
drop table fr_t_parameter;
create table fr_t_parameter(
code varchar(10),
name varchar(40),
content varchar(10));
insert into fr_t_parameter(code,name,content) values('pageline','分页数','20'); /* 调整该参数可以修改每页行数 */
程序1:mainforum.php
<html>
<head>
<link rel="STYLESHEET" type="text/css" href="/blog_article/fp_zhangcg.css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Microsoft Theme" content="none">
<meta name="Microsoft Border" content="none">
<title>论坛</title>
</head>
<body bgcolor="#C0C0C0" background="backcolor.GIF">
<?
include ("c:mydbheader.inc");
?>
<table width="100%" border="0">
<tr >
<td width="50%"> <div align="left">当前位置:主页——论坛</div> </td>
<td width="20%"> <div align="center"> </div> </td>
<td width="10%"> <div align="center">
<A href="/blog_article/addmember.html" target=_blank>会员注册</A></div> </td>
<td width="10%"> <div align="center">论坛搜索</div> </td>
<td width="10%"> <div align="center"> </div> </td>
</table>
<?
$dbh = mysql_connect('localhost:3306','root','');
mysql_select_db('test');
$res=mysql_query("SELECT content FROM fr_t_parameter where code = 'pageline'",$dbh);
$row=mysql_fetch_array($res);
global $pageline;
$pageline = $row["content"];
if (empty($pageline)) {
$res=mysql_query("insert into fr_t_parameter(code,name,content) values('pageline','分页数','20')",$dbh);
$row=mysql_fetch_array($res);
$pageline = 20;
}
$res=mysql_query("SELECT COUNT(*) AS rcnt FROM fr_t_forumtitle",$dbh);
$row=mysql_fetch_array($res);
$rcount = $row["rcnt"];
$res=mysql_query("SELECT COUNT(*) AS rcnt_con FROM fr_t_forumcontent",$dbh);
$row=mysql_fetch_array($res);
$rcon_count = $row["rcnt_con"];
print '<table width="100%" border="0">';
print '<tr >';
print '<td width="15%"> </td>';
print '<td width="35%"> <div align="left"> ';
print "主题数:".$rcount." 帖子数:".$rcon_count;
print '<td width="35%"> <div align="right"> ';
print '<a href="/blog_article/addforum/theme_id/0.html" target="_top"><img src="/blog_article/post.gif" alt="加新帖子" border="0"></a>';
print '<td width="15%"> </td>';
print '</td></table>';
$pages=ceil($rcount / $pageline); //$pages变量现在包含所需的页数
if (empty($offset)) {
$offset=1;
$curline = 0;
} else
$curline = ($offset - 1) * $pageline;
//打印表头
print '<table width="100%" border="0">';
print '<tr > <td width="50%"> <div align="center">';
if ($offset <> 1) { //如果偏移量是0,不显示前一页的链接
$newoffset=$offset - 1;
print "<a href='/blog_article/$PHP_SELF/offset/$newoffset.html'>前一页</a>";
} else {
print "前一页";
print " ";
}
//计算总共需要的页数
$pages=ceil($rcount/$pageline); //$pages变量现在包含所需的页数
程序由三部分组成,即显示主题信息,显示论坛信息,增加论坛信息,主题与论坛内容采用主从表关系。
表结构如下:
drop table fr_t_forumtitle;
create table fr_t_forumtitle(
id integer,
state varchar(1),
readcount integer,
replycount integer,
title varchar(100),
createman varchar(20),
replyman varchar(20),
replytime datetime);
drop table fr_t_forumcontent;
create table fr_t_forumcontent(
id integer,
replyman varchar(20),
replytime datetime,
replyemail varchar(100),
replyhttp varchar(100),
replyface smallint,
content text);
drop table fr_t_parameter;
create table fr_t_parameter(
code varchar(10),
name varchar(40),
content varchar(10));
insert into fr_t_parameter(code,name,content) values('pageline','分页数','20'); /* 调整该参数可以修改每页行数 */
程序1:mainforum.php
<html>
<head>
<link rel="STYLESHEET" type="text/css" href="/blog_article/fp_zhangcg.css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Microsoft Theme" content="none">
<meta name="Microsoft Border" content="none">
<title>论坛</title>
</head>
<body bgcolor="#C0C0C0" background="backcolor.GIF">
<?
include ("c:mydbheader.inc");
?>
<table width="100%" border="0">
<tr >
<td width="50%"> <div align="left">当前位置:主页——论坛</div> </td>
<td width="20%"> <div align="center"> </div> </td>
<td width="10%"> <div align="center">
<A href="/blog_article/addmember.html" target=_blank>会员注册</A></div> </td>
<td width="10%"> <div align="center">论坛搜索</div> </td>
<td width="10%"> <div align="center"> </div> </td>
</table>
<?
$dbh = mysql_connect('localhost:3306','root','');
mysql_select_db('test');
$res=mysql_query("SELECT content FROM fr_t_parameter where code = 'pageline'",$dbh);
$row=mysql_fetch_array($res);
global $pageline;
$pageline = $row["content"];
if (empty($pageline)) {
$res=mysql_query("insert into fr_t_parameter(code,name,content) values('pageline','分页数','20')",$dbh);
$row=mysql_fetch_array($res);
$pageline = 20;
}
$res=mysql_query("SELECT COUNT(*) AS rcnt FROM fr_t_forumtitle",$dbh);
$row=mysql_fetch_array($res);
$rcount = $row["rcnt"];
$res=mysql_query("SELECT COUNT(*) AS rcnt_con FROM fr_t_forumcontent",$dbh);
$row=mysql_fetch_array($res);
$rcon_count = $row["rcnt_con"];
print '<table width="100%" border="0">';
print '<tr >';
print '<td width="15%"> </td>';
print '<td width="35%"> <div align="left"> ';
print "主题数:".$rcount." 帖子数:".$rcon_count;
print '<td width="35%"> <div align="right"> ';
print '<a href="/blog_article/addforum/theme_id/0.html" target="_top"><img src="/blog_article/post.gif" alt="加新帖子" border="0"></a>';
print '<td width="15%"> </td>';
print '</td></table>';
$pages=ceil($rcount / $pageline); //$pages变量现在包含所需的页数
if (empty($offset)) {
$offset=1;
$curline = 0;
} else
$curline = ($offset - 1) * $pageline;
//打印表头
print '<table width="100%" border="0">';
print '<tr > <td width="50%"> <div align="center">';
if ($offset <> 1) { //如果偏移量是0,不显示前一页的链接
$newoffset=$offset - 1;
print "<a href='/blog_article/$PHP_SELF/offset/$newoffset.html'>前一页</a>";
} else {
print "前一页";
print " ";
}
//计算总共需要的页数
$pages=ceil($rcount/$pageline); //$pages变量现在包含所需的页数
[2]一个简单的php实现的MySQL数据浏览器
来源: 互联网 发布时间: 2013-11-30
这个程序可以用来浏览MySQL中的数据,您可以稍做修改就可以做出很不错的MySQL浏览器.
*/
/*
?cmd=db
?cmd=table&db={}
?cmd=record&db={}&table={}
*/
$host = 'localhost';
$user = 'test';
$password = '';
if(!isset($cmd)) $cmd = 'db';
switch($cmd){
case 'db':
break;
case 'table':
break;
case 'record':
break;
default:
$cmd = 'db';
break;
}
$con = @mysql_connect($host,$user,$password) or die('无法连接'.$host);
switch($cmd){
case 'db':
$dbs = mysql_list_dbs($con) or die('mysql_list_dbs 出错:'.$php_errmsg);
echo 'databases on '.$host.':<br>'.chr(13);
$num_rows = mysql_num_rows($dbs);
for($i=0;$i<$num_rows;$i++){
$db = mysql_tablename($dbs,$i);
echo ' <a href="'.$PHP_SELF.'?cmd=table&db='.
urlencode($db).'">'.$db.'</a><br>'.chr(13);
}
mysql_free_result($dbs);
break;
case 'table':
$tables = @mysql_list_tables($db,$con) or die('mysql_list_tables 出错:'.
$php_errmsg);
echo 'tables on '.$db.' of '.$host.':<br>'.chr(13);
$num_rows = mysql_num_rows($tables);
for($i=0;$i<$num_rows;$i++){
$table = mysql_tablename($tables,$i);
echo ' <a href="'.$PHP_SELF.'?cmd=record&db='.
urlencode($db).'&table='.urlencode($table).'">'.$table.'</a><br>'.
chr(13);
}
mysql_free_result($tables);
echo '<hr><a href="'.$PHP_SELF.'?cmd=db">show databases</a>'.chr(13);
break;
case 'record':
$records = mysql_db_query($db,'select * from '.$table,$con) or
die('mysql_db_query 出错:'.$php_errmsg);
echo 'records on '.$table.':<br>'.chr(13);
echo '<table border="1" cellspacing="0" cellpadding="0">'.chr(13);
echo '<tr>'.chr(13);
$num_fields = mysql_num_fields($records);
for($i=0;$i<$num_fields;$i++)
echo '<th> '.mysql_field_name($records,$i).'</th>'.chr(13);
echo '</tr>'.chr(13);
while($row=mysql_fetch_row($records)){
echo '<tr>'.chr(13);
for($i=0;$i<$num_fields;$i++)
echo '<td> '.$row[$i].'</td>'.chr(13);
echo '</tr>'.chr(13);
}
echo '</table>'.chr(13);
mysql_free_result($records);
echo '<hr><a href="'.$PHP_SELF.'?cmd=db">show databases</a>
<a href="'.$PHP_SELF.'?cmd=table&db='.urlencode($db).'">show tables
</a>'.chr(13);
break;
}
mysql_close($con) or die('无法与'.$host.'断开连接');
?>
*/
/*
?cmd=db
?cmd=table&db={}
?cmd=record&db={}&table={}
*/
$host = 'localhost';
$user = 'test';
$password = '';
if(!isset($cmd)) $cmd = 'db';
switch($cmd){
case 'db':
break;
case 'table':
break;
case 'record':
break;
default:
$cmd = 'db';
break;
}
$con = @mysql_connect($host,$user,$password) or die('无法连接'.$host);
switch($cmd){
case 'db':
$dbs = mysql_list_dbs($con) or die('mysql_list_dbs 出错:'.$php_errmsg);
echo 'databases on '.$host.':<br>'.chr(13);
$num_rows = mysql_num_rows($dbs);
for($i=0;$i<$num_rows;$i++){
$db = mysql_tablename($dbs,$i);
echo ' <a href="'.$PHP_SELF.'?cmd=table&db='.
urlencode($db).'">'.$db.'</a><br>'.chr(13);
}
mysql_free_result($dbs);
break;
case 'table':
$tables = @mysql_list_tables($db,$con) or die('mysql_list_tables 出错:'.
$php_errmsg);
echo 'tables on '.$db.' of '.$host.':<br>'.chr(13);
$num_rows = mysql_num_rows($tables);
for($i=0;$i<$num_rows;$i++){
$table = mysql_tablename($tables,$i);
echo ' <a href="'.$PHP_SELF.'?cmd=record&db='.
urlencode($db).'&table='.urlencode($table).'">'.$table.'</a><br>'.
chr(13);
}
mysql_free_result($tables);
echo '<hr><a href="'.$PHP_SELF.'?cmd=db">show databases</a>'.chr(13);
break;
case 'record':
$records = mysql_db_query($db,'select * from '.$table,$con) or
die('mysql_db_query 出错:'.$php_errmsg);
echo 'records on '.$table.':<br>'.chr(13);
echo '<table border="1" cellspacing="0" cellpadding="0">'.chr(13);
echo '<tr>'.chr(13);
$num_fields = mysql_num_fields($records);
for($i=0;$i<$num_fields;$i++)
echo '<th> '.mysql_field_name($records,$i).'</th>'.chr(13);
echo '</tr>'.chr(13);
while($row=mysql_fetch_row($records)){
echo '<tr>'.chr(13);
for($i=0;$i<$num_fields;$i++)
echo '<td> '.$row[$i].'</td>'.chr(13);
echo '</tr>'.chr(13);
}
echo '</table>'.chr(13);
mysql_free_result($records);
echo '<hr><a href="'.$PHP_SELF.'?cmd=db">show databases</a>
<a href="'.$PHP_SELF.'?cmd=table&db='.urlencode($db).'">show tables
</a>'.chr(13);
break;
}
mysql_close($con) or die('无法与'.$host.'断开连接');
?>
[3]php实现的MySQL通用查询程序
来源: 互联网 发布时间: 2013-11-30
if(get_magic_quotes_gpc()==1){
?>
<html>
<head><title>MySQL通用查询程序</title></head>
<body>
注意本程序需要将PHP配置文件(PHP3为php3.ini,PHP4为php.ini)中的magic_quotes_gpc
设成Off或0,修改后请重新启动Apache.
</body>
</html>
<?
exit();
}
set_magic_quotes_runtime(0);
$host = 'localhost';
$db = 'test';
$user = 'test';
$pass = '';
// [ php/inc/str2url.php ] cvs 1.2
function str2url(/blog_article/$path/index.html){
return eregi_replace("%2f","/",urlencode($path));
}
?>
<html>
<head><title>MySQL通用查询程序</title></head>
<body>
<form action="/blog_article/</echo str2url(/blog_article/$PHP_SELF/index.html);/gt;.html" method="post">
请输入SQL语句:<br>
<textarea name="sql" cols="100" rows="5"><?echo $sql;?></textarea><br>
<input type="submit" name="cmd" value="查询">
<input type="submit" name="cmd" value="执行">
</form>
<?
if($cmd){
$con = mysql_pconnect($host,$user,$pass) or die('无法连接'.$host.'服务器');
mysql_select_db($db,$con) or die('无法连接'.$db.'数据库');
$rst = mysql_query($sql,$con) or die($sql.'出错');
if($cmd=='查询'){
$num_fields = mysql_num_fields($rst);
echo '<hr>';
echo '<table border="1" cellpadding="0" cellspacing="0">';
echo '<caption align="center">'.$sql.'</option>';
echo '<tr>';
for($i=0;$i<$num_fields;$i++) echo '<th> '.mysql_field_name($rst,$i).'</th>';
echo '</tr>';
while($row=mysql_fetch_row($rst)){
echo '<tr>';
for($i=0;$i<$num_fields;$i++) echo '<td> '.$row[$i].'</td>';
echo '</tr>';
}
echo '</table>';
mysql_free_result($rst);
}
else echo '有 '.mysql_affected_rows($con).' 行受影响';
}
?>
</body>
</html>
?>
<html>
<head><title>MySQL通用查询程序</title></head>
<body>
注意本程序需要将PHP配置文件(PHP3为php3.ini,PHP4为php.ini)中的magic_quotes_gpc
设成Off或0,修改后请重新启动Apache.
</body>
</html>
<?
exit();
}
set_magic_quotes_runtime(0);
$host = 'localhost';
$db = 'test';
$user = 'test';
$pass = '';
// [ php/inc/str2url.php ] cvs 1.2
function str2url(/blog_article/$path/index.html){
return eregi_replace("%2f","/",urlencode($path));
}
?>
<html>
<head><title>MySQL通用查询程序</title></head>
<body>
<form action="/blog_article/</echo str2url(/blog_article/$PHP_SELF/index.html);/gt;.html" method="post">
请输入SQL语句:<br>
<textarea name="sql" cols="100" rows="5"><?echo $sql;?></textarea><br>
<input type="submit" name="cmd" value="查询">
<input type="submit" name="cmd" value="执行">
</form>
<?
if($cmd){
$con = mysql_pconnect($host,$user,$pass) or die('无法连接'.$host.'服务器');
mysql_select_db($db,$con) or die('无法连接'.$db.'数据库');
$rst = mysql_query($sql,$con) or die($sql.'出错');
if($cmd=='查询'){
$num_fields = mysql_num_fields($rst);
echo '<hr>';
echo '<table border="1" cellpadding="0" cellspacing="0">';
echo '<caption align="center">'.$sql.'</option>';
echo '<tr>';
for($i=0;$i<$num_fields;$i++) echo '<th> '.mysql_field_name($rst,$i).'</th>';
echo '</tr>';
while($row=mysql_fetch_row($rst)){
echo '<tr>';
for($i=0;$i<$num_fields;$i++) echo '<td> '.$row[$i].'</td>';
echo '</tr>';
}
echo '</table>';
mysql_free_result($rst);
}
else echo '有 '.mysql_affected_rows($con).' 行受影响';
}
?>
</body>
</html>
最新技术文章: