WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : a smart list board on index for use for communication
Categories : MS SQL Server, PHP Update Picture
sanry ma
Date : Mar 28th 2000
Grade : 2 of 5 (graded 2 times)
Viewed : 5239
File : list.php3
Images : No Images for this code example.
Search : More code by sanry ma
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

//the following is list.php3
<head>
<STYLE TYPE="text/css">
td{ font-size: 9pt }
td.note{font-size:10.5pt}
.input {background="#ccddff";font-size: 9pt}
A:link {text-decoration:none}
A:hover {color:red;text-decoration:underline}
</style>
</head>
<?
switch($modID){
case 0:
include "list.inc";
//***********************Connect the db*****************************
$db=mysql_connect($server,$uid,$pwd);
mysql_select_db($dbname,$db);
//********************Insert a record*******************************
if($name&&$mess) {
$date=date("y-m-d H:i:s");
$date=strval($date);
$flag=date("z");
$flag=intval($flag);
$sql="insert into book(name,title,mess,date,flag,email)
values('$name','$title','$mess','$date','$flag','$email')";
$result=mysql_query($sql);
@mysql_free_result($result);
         echo"<meta http-equiv=\"refresh\" content=\"0;URL=$PHP_SELF\">";
}
$sql = "select count(*) as total from book";//生成查询记录数的SQL语句
$rst = mysql_query($sql);
$row = mysql_fetch_array($rst) ;
$rowcount = $row["total"];//取出记录数
mysql_free_result($rst);
$pagecount = bcdiv($rowcount+$pagesize-1,$pagesize,0);//算出总共有几页
if(!isset($pageno)) $pageno = $pagecount;//在没有设置pageno时,缺省为显示第1页
if($pageno<1) $pageno = 1;//若pageno比1小,则把它设置为1
if($pageno>$pagecount) $pageno = $pagecount;//若pageno比总共的页数大,则把它设置为最后
一页
echo "<table width=\"92%\" cellpadding=\"5\" cellspacing=\"0\" bgcolor=\"#ddffff\"
align=\"center\" border=\"1\" bordercolorlight=\"#000000\" bordercolordark=\"#FFFFFF\">
<tr>
<td class=note>资讯交流</td>
  <td class=note><a href=\"$PHP_SELF?modID=1\">添加资讯</a></td>";
        if($pageno>0){
$href = eregi_replace("%2f","/",urlencode($PHP_SELF));
         if($pageno>1){//显示上一页的裢接
echo '<td ><a class=note href="' . $href . '?pageno=' . ($pageno-1) . '">前一页
</a></td>';
}
else{
echo '<td>前一页</td>';
}
if($pageno<$pagecount){//显示下一页的裢接
echo '<td><a class=note href="' . $href . '?pageno=' . ($pageno+1) . '">下一页
</a></td>';
}
else{
echo '<td>下一页</td>';
}
echo "</tr></table>";
$sql = "select * from book order by id desc LIMIT 0,$pagesize";//生成查询本页数据的SQL语句
$rst = mysql_query($sql);//查询本页数据
$num_fields = mysql_num_fields($rst);//取得字段总数
echo mysql_error();
         $i = 0;
while($i<$num_fields){//取得所有字段的名字
$fields[$i] = mysql_field_name($rst,$i);//取得第i+1个字段的名字
$i++;
}

echo "<table width=\"92%\" cellpadding=\"5\" cellspacing=\"0\" align=\"center\" border=\"1\"
bordercolorlight=\"#000000\" bordercolordark=\"#FFFFFF\">\n";        
while ($myrow=mysql_fetch_array($rst)) {         
         printf("<tr><td bgcolor=\"ACD3FF\">
                 <a href=\"$PHP_SELF?id=$myrow[id]&pageno=$pageno#$myrow[id]\">
                 标题:%s牋牋
                 姓名:<strong>%s<strong></a></td>
                 <td bgcolor=\"#ddffff\">来源:%s
<a name=\"$myrow[id]\">时间:%s</a></td></tr>\n",
$myrow[title],$myrow[name],$myrow[email],'20'.$myrow[date]);
                 if ($myrow[id]==$id) {
                 echo "<tr><td bgcolor=\"cee5ff\"><font color=\"004890\">内容:</font>
                 <pre>".$myrow[mess]."</pre></td></tr>";
}
}
}
echo "</table>";
@mysql_free_result($ret);
$action="null";
//******************************************************************
mysql_close($db);
break;
case 1;
echo '<hr><div align=center>
<a name="post"><b>欢迎来到资讯中心</b></a><br>
<form action="'.$PHP_SELF.'?" method="POST">
标题:
<input type="Text" name="title" size="40" maxlength="50" class="input"><br>
姓名 :
<input type="Text" name="name" size="40" maxlength="50" class="input"><br>
EMAIL:
<input type="Text" name="email" size="40" maxlength="50" class="input"><br>
内容:<br>
<textarea name="mess" cols="48" rows="8" wrap="hard" class="input"></textarea><br>
<input type="Submit" name="action" value="Submit" class="input">
<input type="reset" class="input">
</form>
</div>
<hr>';
$modID=0;
break;
}
?>


//the following is list.inc
<?
$server="localhost"; //mysql server address
$dbname="sanry"; // mysql database name
$uid="jtan"; // username for that database
$pwd="8888"; // password for that database
$pagesize = 10;//每页显示10条记录
?>



Guestbook sort by descending date and can view page by page
Categories : PHP, MS SQL Server, Databases
Recordset Class for MSSQL database
Categories : PHP Classes, Databases, PHP, MS SQL Server
How to connect to MS SQL 6.x+ database server via ODBC functions of PHP3 compiled with iODBC and Openlink drivers under Linux.
Categories : Databases, MS SQL Server, PHP, ODBC
Simple class for accessing databases like MSSql Server, Oracle etc by Raju
Categories : PHP, MS SQL Server, Databases, PHP Classes, Oracle
Scripts to build APACHE - PHP and SQL 7.0
Categories : PHP, Databases, MS SQL Server
Convert SQL from oracle,mysql,mssql,sqlite and odbc to SQL compatible
Categories : PHP, PHP Classes, Databases, MySQL, MS SQL Server
[PHP5] aDB PDO LIKE Database Abstraction. Switch easily from one db server to another, strong errors management, manage transactions, queries preparation and more.
Categories : PHP, PHP Classes, Databases, MS SQL Server, MySQL
Mssql database Manager
Categories : PHP, Databases, MS SQL Server, Classes and Objects, PHP Classes
mssql_close -- Close MS SQL Server connection
Categories : PHP, PHP Functions, MS SQL Server
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Unable to select text bigger than 4K from MSsql
Categories : PHP, WinNT, Databases, MS SQL Server
Cut your MySQL Connections to 1 line of code
Categories : PHP, Beginner Guides, Databases, MySQL
A simple class with some HTML output functions that would come in handy for consistent page layout etc.
Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation
recode -- Recode a string according to a recode request
Categories : PHP, PHP Functions, Recode
PhpIBadmin - Web interface to Interbase RBDMS , this is a port of phpMyadmin
Categories : Databases, InterBase, PHP