Development example: display the latest 10 news


Display the latest 10 news program writing examples Program code writing Storage directory format:
Plug-in program storage directory: /e/extend/newnews/
Plug-in template storage directory uses: /e/extend/newnews/template/
Required program files:
/e/extend/newnews/index.php Main program file
/e/extend/newnews/template/index.temp.php Main program template file

Program Directory Template Directory
Main program file content(/e/extend/newnews/index.php):
<?php
require('../../class/connect.php'); //Introduce database configuration files and public function files
require('../../class/db_sql.php'); //Introduce database operation files
require('../../data/dbcache/class.php'); //Introduce column cache files
$link=db_connect(); //Connect to MYSQL
$empire=new mysqlquery(); //Declare database operation class
$editor=1; //Declare directory hierarchy

$sql=$empire->query("select * from {$dbtbpre}ecms_news order by newstime limit 10"); //Query the latest 10 records in the news table
require('template/index.temp.php'); //Import template file

db_close(); //Close the MYSQL link
$empire=null; //Cancel operation class variables
?>


Main program template file content(/e/extend/newnews/template/index.temp.php):
Note: The template can be visually produced with Dreamweaver. The blue part of the code does not allow direct access to the template file.
<?php
if(!defined('InEmpireCMS'))
{
exit();
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content- Type" content="text/html; charset=gb2312">
<title>Display the latest 10 news examples</title>
</head>
<body>
<br>
<br>
<br>
<table width="500" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td height="25"><strong>Display the latest 10 news: </strong></td>
</tr>
<tr>
<td height="25" bgcolor="#FFFFFF">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                                                                                                                                                                                                                                               //Loop to obtain query records
                                                                                                                                $titleurl=sys_ReturnBqTitleLink($r); //Title link
            ?>
                                                                                                                                                                                                                         height="25">·<a href="<?=$titleurl?>" target="_blank">
                  <?=esub(stripslashes($r[title]),32)?>
                                                                                                                                                                                                                                                                                                                                                                    <td width="33%"><div align="center">[<?=date('Y-m-d',$r[newstime])?>]</div></td>
                                                                                                                                        }
            ?>
                                                                                                                            </td>
</tr>
</table>
</body>
</html>



Access the main program of the Hello World plug-in file: /e/extend/newnews/index.php