PHP Classic Project Case-(a) blog management System 3

Source: Internet
Author: User
Tags php class strcmp

This article gives first to the left navigation bar and the right announcement area.

Six, left navigation bar:

1. Calendar:

Here is a single PHP file, which can be referenced directly in the place where the calendar is displayed:

cale.php

<?php class calendar{Private $year, $month, $day;     Private $week =array ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");         Private $_month=array ("he" and "January", "Geneva" and "February", "I" and "March", "I" and "April", "10" and "May", "he" and "June", "" "and" July "," he "and" August "," he "and" September "," =& " gt; "     October "," one by one "=" November "," One "and" December ";     function Setyear ($year) {//Set year $this->year= $year;     } function getyear () {//Get year return $this->year;     } function Setmonth ($month) {//Set month $this->month= $month;     } function GetMonth () {//Get month return $this->month;     } function Setday ($day) {//Set date $this->day= $day;     } function Getday () {//Get date return $this->day; } function out () {//Output calendar $this->_env ();//Set date displayed $week = $this->getweek ($this->year, $this-&gt ; month, $thiS->day);     Day of the week $fweek = $this->getweek ($this->year, $this->month,1); Get the first day of the month for the days of the Week echo "<div style=width:255;font:9pt> <form action=$_server[php_self] method= ' post ' style= ' m argin:0 ' > <select name= ' month ' onchange= ' this.form.submit (); '         > ";             for ($ttmpa =1; $ttmpa <13; $ttmpa + +) {//output 12 months $TTMPB =sprintf ("%02d", $ttmpa);             if (strcmp ($TTMPB, $this->month) ==0) {$select = "selected Style= ' Background-color: #FAFDE2 '";             }else{$select = ""; } echo "<option value= ' $TTMPB ' $select >". $this->_month[$TTMPB]. "         </option> "; } echo "</select> <select name= ' year ' onchange= ' This.form.submit (); '    > ";                 Output year, before and after 10 years for ($ctmpa = $this->year-10; $ctmpa < $this->year+10; $ctmpa + +) {if ($ctmpa >2050) {             Break    } if ($ctmpa <1980) {continue;         } if (strcmp ($ctmpa, $this->year) ==0) {$select = "selected Style= ' Background-color: #FA             FDE2 ' ";             }else{$select = "";         } echo "<option value= ' $ctmpa ' $select > $ctmpa </option>";         } echo "</select> </form><br/> <table border=0 align=center>"; for ($Tmpa =0; $Tmpa <count ($this->week), $Tmpa + +) {//Output week header echo <td>. $this->week[$Tmpa]. "         </td> ";              } for ($TMPB =1; $TMPB <=date ("T", Mktime (0,0,0, $this->month, $this->day, $this->year)), $TMPB + +) {//Output all dates             if (strcmp ($TMPB, $this->day) ==0) {//Get the current date and use the featured color as the marker $flag = "bgcolor= ' #FF3366 '";             }else{$flag = ' bgcolor= #FAFDE2 ';                 } if ($TMPB ==1) {echo "<tr>"; for ($TMPC =0; $tmpc < $fweek; $TMPC + +) {echo <td></td> ";                }} if (strcmp ($this->getweek ($this->year, $this->month, $TMPB), 0) ==0) {//if it is Sunday             echo "<tr><td align= ' center ' $flag > $TMPB </td>";             }else{echo "<td align= ' center ' $flag > $TMPB </td>";    }} echo "</table></div>";     }//Gets the number of days specified in the method for the day of the week function Getweek ($year, $month, $day) {$week =date ("W", Mktime (0,0,0, $month, $day, $year));   Get the week return $week;         Get Week} function _env () {if (Isset ($_post["Month")) {$month =$_post["month"];          }else{$month =date ("M");//The default is this month} if (Isset ($_post["Year")) {$year =$_post[' year '];    }else{$year =date ("Y");        The default is this year} $this->setyear ($year);        $this->setmonth ($month);        $date =sprintf ('%1d ', date (' d '));    $this->setday ($date); }} $D =new calendAr   $D->out ();?>

Directly referencing the file in index.php

<!--calendar Display-<tr> <span style= "White-space:pre" ></SPAN><TD height= "155" align= "center" valign= "Top" ><?php include ' cale.php ';? ></td> </tr>

2, the latest article shows:

<!--latest article shows--><tr><span style= "White-space:pre" ></span><td height= "" "Align=" center " valign= "Top" > <table width= "$" border= "0" cellpadding= "0" cellspacing= "0" > <tr> &lt Span style= "White-space:pre" ></span><td> <table width= "201" border= "0" cellpadding= "0" C ellspacing= "0" style= "margin-top:25px" valign= "Top" > </table> </td> &L  t;/tr> <?php $sql = "Select Id,title from tb_article ORDER by ID                DESC LIMIT 5 ";                $res = $sqlHelper->execute_dql ($sql);                $i = 1; while ($info = $res->fetch_assoc ()) {?> <tr> <span style= "White-space:pre" &GT;&LT;/SPAN&G T;&LT;TD width= "201" align= "left" valign= "top" > <a href= "article.php?file_id=<?php echo $info [' ID ' ];? > "target=" _blank "><font size=" 2 "><?php echo $i. ",". substr ($info [' title '],0,27);?                ></font></a> </td> </tr> <?php $i = $i +1;  }?> <tr> <td height= "Ten" align= "right" ><a href= "file_more.php" >   </a></td> </tr> </table> </td></tr>
I used my own tool class when I went to query the database sqlHelper.class.php

Here is the implementation code for the method used above:

sqlHelper.class.php part of the code:

 Class sqlhelper{public $mysqli;        Public $dbname = "Db_tmlog";        Public $username = "root";        Public $password = "root";                Public $host = "localhost"; Public Function __construct () {$this->mysqli = new Mysqli ($this->host, $this->username, $this->pass            Word, $this->dbname);            if ($this->mysqli->connect_error) {die ("Connection failed". $this->mysqli->connect_error);        } $this->mysqli->query ("Set names UTF8"); }//Execute DQL statement public Function EXECUTE_DQL ($sql) {$res = $this->mysqli->query ($sql            ) or Die ($this->mysqli->error);        This returns a result set that, when called $row = $res->fetch_assoc () is a one-way down, should use the while loop return $res;                                                                                                                           } <span style= "font-family:arial, Helvetica, Sans-serif;" >}</spaN> 

The DQL statement is a simple query statement.

Before using a database query, wrap the file in, then new a tool class object, and then use the object to invoke the function inside.


3, the latest picture display

<!--latest pictures show--><tr><span style= "White-space:pre" &GT;&LT;/SPAN&GT;&LT;TD height= "201" align= "center"         valign= "Top" ><br/> <table width= "145" border= "0" cellspacing= "0" cellpadding= "0" > <tr> <span style= "White-space:pre" ></span><td> <table width= "201" border= "0" cells pacing= "0" cellpadding= "0" valign= "top" style= "margin-top:5px;" > <?php<span style= "white-space:pre" ></span> $sql = "Select Id,tpmc,file from TB_TPSC order by id desc limit 2 "; $res 2 = $sqlHelper->execute_dql ($sql), while ($info = $res 2->fetch_assoc ()) {<span style="                    White-space:pre "></span> $query =" SELECT * from TB_TPSC where id= ". $info [' id '];                    <span style= "White-space:pre" ></span> $result = $sqlHelper->execute_dql ($query); <span style= "White-space:pre" ></span>if ($row = $result->fetch_assoc ()) {<span StYle= "White-space:pre" ></span> $data = $row [' file ']; <span style= "White-space:pre" ></span>}?><tr> <span style= "White-space:pre" ></span &GT;&LT;TD width= "9" rowspan= "2" align= "center" > </td> <td width= "147" align= "center" > &lt A href= "image.php?recid=<?php echo $info [' id '];?>" target= "_blank" >  "width=" height= "border=" 0 "> </a> </td> <td width=" "rowspan=" 2 "align=" ce Nter "> </td> </tr> <tr> <td align=" center "> Picture name: <?php echo $info [' tpmc '];? ></td></tr><?php}?><tr><span style= "White-space:pre" ></span><td Colspan= "3" height= "ten" align= "right" ><a href= "pic_more.php" >   </a></td></tr> &LT;/TABLE&GT </td> </tr> </table> </td></tr>

Database queries are also used.

4. Realization of Announcement Area

Used a label I hadn't seen before in the announcement area <marquee>

It has a set of properties that stop scrolling when the mouse hovers over it and start scrolling when it leaves.


<?php<span style= "White-space:pre" ></span> $p _sql = "SELECT * from Tb_public ORDER by id DESC";        $p _rst = $sqlHelper->execute_dql ($p _sql);? ><marquee onmouseover= "This.stop ()" style= "WIDTH:426PX; height:280px "onmouseout=" This.start () "scrollamount=" 2 "scrolldelay=" 7 "direction=" Up "align=" "><span style=" Font-size:9pt "><center><?php<span style=" White-space:pre "></span>while ($p _row = $p _rst- >fetch_row ()) {><a href= "#" onclick= "Wopen=open (' show_pub.php?id=<?php echo $p _row[0];?> ', ', ' Height=200,width=1000,scollbars=no ') "><?php echo $p _row[1];?></a><br> <?php        }?> </center></span></marquee>
This tag is HTML5 new, and the center tag. Then in the use of the time will appear below the picture of the yellow wavy line, I did not control him.

In the <a> this hyperlink tag, it sets the onclick attribute, the OnClick property followed by the JS file must be inside the function, this is to open a custom wide window. href= "#" means that the hyperlink is not connected to another page, where the response to the hyperlink is set using the onclick.


Here, our homepage is basically realized. This is index.php's full code: index.php Extraction Code: IU09


PHP Classic Project Case-(a) blog management System 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.