Home Backend Development PHP Tutorial Minecraft mobile version seed code encyclopedia PHP common code encyclopedia is a must for beginners

Minecraft mobile version seed code encyclopedia PHP common code encyclopedia is a must for beginners

Jul 29, 2016 am 08:43 AM

1. Connect MYSQL database code
$c or die("Cannot connect to database server: ".mysql_error());
mysql_select_db("liuyanben",$connec) or die ("Cannot select database: ". mysql_error());
mysql_query("set names 'gbk'");
?>
2. Read the database and implement loop output
$sql="select * from liuyan order by ly_id desc ";
$c
while($rs=mysql_fetch_array($conn)){
?>
The content of the loop...
}
?>
3. How Implement paging, including two functions and two calls
1) Two functions
//Page function
function genpage(&$sql,$page_size=2)
{
global $prepage,$nextpage,$ pages,$sums; //out param
$page = $_GET["page"];
$eachpage = $page_size;
$pagesql = strstr($sql," from ");
$pagesql = "select count( *) as ids ".$pagesql;
$conn = mysql_query($pagesql) or die(mysql_error());
if($rs = mysql_fetch_array($conn)) $sums = $rs[0];
$pages = ceil(($sums-0.5)/$eachpage)-1;
$pages = $pages>=0?$pages:0;
$prepage = ($page>0)?$page-1:0;
$nextpage = ($page<$pages)?$page+1:$pages;
$startpos = $page*$eachpage;
$sql .=" limit $startpos,$eachpage ";
}
// Display paging
function showpage()
{
global $page,$pages,$prepage,$nextpage,$queryString; //param from genpage function
$shownum =10/2;
$startpage = ($page>=$shownum) ?$page-$shownum:0;
$endpage = ($page+$shownum<=$pages)?$page+$shownum:$pages;
echo "Total".($pages+1)."Page: ";
if($page>0)echo "Homepage";
if($startpage>0)
echo " ... ?";
for($i=$startpage;$i< ;=$endpage;$i++)
{
if($i==$page) echo " [".($i+1)."] ";
else echo " < ;a href=$PHP_SELF?page=$i$queryString>".($i+1)." ";
}
if($endpage<$pages)
echo "< ;a href=$PHP_SELF?page=".($page+$shownum*2)."$queryString>? ... ";
if($page<$pages)
echo "Last page";
}
//Show classified paging
function showpage1()
{
$fenlei=$_GET[ "fenleiid"];
global $page,$pages,$prepage,$nextpage,$queryString; //param from genpage function
$shownum =10/2;
$startpage = ($page>=$shownum)?$ page-$shownum:0;
$endpage = ($page+$shownum<=$pages)?$page+$shownum:$pages;
echo "total".($pages+1)."page: ";
if ($page>0)echo "Homepage";
if($startpage>0)
echo " ... ?";
for($i=$ startpage;$i<=$endpage;$i++)
{
if($i==$page) echo " [".($i+1)."] ";
else echo " ".($i+1)." ";
}
if($endpage<$pages)
echo "? ... ";
if($page<$pages)
echo "last page}
?>
2 ) Two calls
The first
$sql="select * from liuyan order by ly_id desc";
genpage($sql); //Just add this line to the normal code and it will be ok.
$c
while($rs=mysql_fetch_array($conn)){
?>
Second
}
?>
showpage(); //Show page
?>
mysql_close();
?>
4. Server-side includes

5. How to write a record into the database , and then prompt and jump to the page
$ly_title=$_POST["ly_title"];
$ly_c
$ly_time=$_POST["ly_time"];
$ly_author=$_POST["ly_author"] ;
$ly_email=$_POST["ly_email"];
$sql="insert into liuyan(ly_title,ly_content,ly_time,ly_author,ly_email) values('".$ly_title."','".$ly_content." ','".$ly_time."','".$ly_author."','".$ly_email."')";
mysql_query($sql,$connec);
echo("");
?>
6. A dialog box pops up and the page jumps.
echo("");
? >
7. Information viewing page (conditional reading of the database)
1) Conditional reading of the database
$sql="select * from liuyan where ly_id=$_GET[id]";
$c
$rs=mysql_fetch_array($conn);
?>
2) Output a certain field

3) Close the database
mysql_close();
?>
8. Update a certain record in the database and make a prompt jump
$ly_title=$_POST["ly_title"];
$ly_c
$ly_time=$_POST[" ly_time"];
$ly_author=$_POST["ly_author"];
$ly_email=$_POST["ly_email"];
$sql="update liuyan set ly_title='$ly_title',ly_c where ly_id=$_GET[ id]";
mysql_query($sql,$connec);
echo("");
?>
9. How to delete a record in the database
$sql="delete from liuyan where ly_id=$_GET[id]";
mysql_query($sql,$connec);
echo("");
?>
10. How to verify member login
session_start();
$username=$_POST["username"] ;
$password=$_POST["password"];
$sql="select * from admin where username='".$username."' && password='".$password."'";
$result= mysql_query($sql,$connec);
if($row=mysql_fetch_array($result)){
session_register("admin");
$admin=$username;
echo("");}
else
{
echo("
13. In PHP How to call the editor in
1) Place the editor folder in the background management folder.
2) Use the following statements to perform the import operation.


Note: The name of the eWebEditorPHP38 editor folder.
id=content in which content is the name of the hidden field above
14. Loop output (can achieve column splitting)
1) First insert a row and a column of tables
$i=1;
?>
< table> ;?php
if ($i % 2==0) {
echo "";
}
$i++;
}
?>

< /table>
15. Bind data to the drop-down list box (and select it by default when modifying)

16. Get character length function
strlen($c)>12
17. Define a character interception function
Usage:
function substrgb($in,$num){
$pos=0;
$out="";
while($c=substr($in,$ pos,1)){
if($c=="n") break;
if(ord($c)>128){
$out.=$c;
$pos++;
$c=substr( $in,$pos,1);
$out.=$c;
}else{
$out.=$c;
}
$pos++;
if($pos>=$num) break;
}
if($out!=$in) $out = $out . "...";
return $out;
}
18. Determine whether it is a number
!is_numeric(qq)
19. Get the current date in PHP technology
$ptime=date("y-m-d");
20. PHP verification program used when user registration
if ($admin=="" or (strlen($admin)>16) or (strlen($admin) <2)) {
echo "";
}
if ($password=="" or strlen($password)>16 or strlen($password)<6) {
echo "";
}
if ($ password=="") {
echo "";
}
}
if ($wt="") {
echo "";
}
if ($da="") {
echo "< SCRIPT language=JavaScript>alert('Question answer cannot be empty');";
echo"this.location.href='vbscript:history.back()';";
}
if ($ qq!="") {
if (!is_numeric($qq)) {
echo "";
}
}
if ($youbian=="" or strlen($youbian)!=6) {
echo "";
}
if ($youbian!="" ) {
if (!is_numeric($youbian)) {
echo "";
}
}
if ($dizhi="") {
echo "";
}
if ($mail=="") {
echo "";
}
if ($textarea=="") {
echo "";
}
if ($textarea=="" or strlen(textarea)>150) {
echo "";
}
24、对输出的内容进行判断,从而输出其它结果
if ($rs["active"]==1) {
echo "激活";
}else{
echo "禁用";
}
?>
25.字符截取函数

26.男女问题或单选带选择的
>男
>女
27.单选不带单选框的

锁定
else{?>
解锁

它的 save页是

$hy_id=$_GET['id'];
$action=$_GET['action'];
if ($action=='yes'){
$sql="update hybiao set hy_zhuangtai='锁定' where hy_id='$id'";
$query=mysql_query($sql,$connec);
echo("");
}
else{
$sql="update hybiao set hy_zhuangtai='正常' where hy_id='$id'";
$query=mysql_query($sql,$connec);
echo("");
}
mysql_close();
?>
28. 如果文字过长,则将过长的部分变成省略号显示


就是比如有一行文字,很长,表格内一行显示不下.

29.
禁止复制,鼠标拖动选取
30.大 中 小 文字的变化

需要指定大小的文字

30.添加到收藏夹和设为首页

32.节日倒计时

33.打开窗口即最大化

34.加入背景音乐
只适用于IE
对Netscape ,IE 都适用
35.滚动

滚动信息

36.防止点击空链接时,页面往往重置到页首端
代码“javascript:void(null)”代替原来的“#”标记
37.不能点右键,不用CTRL+A,不能复制作!





39.如何关闭层






43.后退&关闭窗口
后退:javascript:history.back(1)
关闭:javascript:window.close();
44.如果文字过长,则将过长的部分变成省略号显示

就是比如有一行文字,很长,表格内一行显示不下.

45. Copying is prohibited, drag the mouse to select

The above introduces the Minecraft mobile version seed code encyclopedia, which is a must-have for beginners to get started with PHP common codes, including the content of the Minecraft mobile version seed code encyclopedia. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

See all articles