PHP经典项目案例-(1)博客管理系统3
PHP经典项目案例-(一)博客管理系统3
本篇给出首页左侧导航栏及右部公告区的实现。
六、左侧导航栏:
1、日历:
这里单独一个php文件,在显示日历的那个地方直接引用该文件即可:
cale.php
<?php class calendar{ private $year,$month,$day; private $week=array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); private $_month=array( "01"=>"一月", "02"=>"二月", "03"=>"三月", "04"=>"四月", "05"=>"五月", "06"=>"六月", "07"=>"七月", "08"=>"八月", "09"=>"九月", "10"=>"十月", "11"=>"十一月", "12"=>"十二月" ); function setyear($year){ //设置年份 $this->year=$year; } function getyear(){ //获得年份 return $this->year; } function setmonth($month){ //设置月份 $this->month=$month; } function getmonth(){ //获得月份 return $this->month; } function setday($day){ //设置日期 $this->day=$day; } function getday(){ //获得日期 return $this->day; } function OUT(){ //输出日历 $this->_env(); //设置显示的日期 $week=$this->getweek($this->year,$this->month,$this->day); //获得日期为星期几 $fweek=$this->getweek($this->year,$this->month,1); //获得此月第一天为星期几 echo "<div style="width:255;font:9pt"> <form action="%24_SERVER%5BPHP_SELF%5D" method="'post'" style="'margin:0'"> <select name="'month'" onchange="'this.form.submit();'">"; for($ttmpa=1;$ttmpamonth)==0){ $select="selected style='background-color:#FAFDE2'"; }else{ $select=""; } echo "<option value="'$ttmpb'">".$this->_month[$ttmpb]."</option>"; } echo " </select> <select name="'year'" onchange="'this.form.submit();'">"; //输出年份,前后10年 for($ctmpa=$this->year-10;$ctmpayear+10;$ctmpa++){ if($ctmpa>2050){ break; } if($ctmpayear)==0){ $select="selected style='background-color:#FAFDE2'"; }else{ $select=""; } echo "<option value="'$ctmpa'">$ctmpa</option>"; } echo "</select> </form> <br> <table border="0" align="center">"; for($Tmpa=0;$Tmpa<count>week);$Tmpa++){ //输出星期的标头 echo "<td>".$this->week[$Tmpa]."</td>"; } for($tmpb=1;$tmpbmonth,$this->day,$this->year));$tmpb++){ //输出所有日期 if(strcmp($tmpb,$this->day)==0){ //获得当前日期,并采用特色颜色做为标记 $flag=" bgcolor='#FF3366'"; }else{ $flag=' bgcolor=#FAFDE2'; } if($tmpb==1){ echo "<tr>"; for($tmpc=0;$tmpc"; } } if(strcmp($this->getweek($this->year,$this->month,$tmpb),0)==0){ //如果是周日 echo "</tr> <tr> <td align="'center'">$tmpb</td>"; }else{ echo "<td align="'center'">$tmpb</td>"; } } echo "</tr></count> </table> </div>"; } //获得方法内指定的日期的星期数 function getweek($year,$month,$day){ $week=date("w",mktime(0,0,0,$month,$day,$year)); //获得星期 return $week; //获得星期 } function _env(){ if(isset($_POST["month"])){ $month=$_POST["month"]; }else{ $month=date("m"); //默认为本月 } if(isset($_POST["year"])){ $year=$_POST["year"]; }else{ $year=date("Y"); //默认为本年 } $this->setyear($year); $this->setmonth($month); $date=sprintf('%1d',date('d')); $this->setday($date); }} $D=new calendar; $D->OUT(); ?>
在index.php里面直接引用该文件
<!-- 日历显示 --> <tr> <span style="white-space:pre"> </span><td height="155" align="center" valign="top"><?php include 'cale.php';?></td> </tr>
2、最新文章显示:
<!-- 最新文章显示 --><tr> <span style="white-space:pre"> </span><td height="125" align="center" valign="top"> <table width="200" border="0" cellpadding="0" cellspacing="0"> <tr> <span style="white-space:pre"> </span><td> <table width="201" border="0" cellpadding="0" cellspacing="0" style="margin-top:25px" valign="top"> </table> </td> </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"> </span><td width="201" align="left" valign="top"> <a href="article.php?file_id=<?php%20echo%20%24info%5B'id'%5D;?>" target="_blank"><font size="2"><?php echo $i."、".substr($info['title'],0,27);?></font></a> </td> </tr> <?php $i=$i+1; } ?> <tr> <td height="10" align="right"><a href="file_more.php"><img src="images/more.gif" style="max-width:90%" style="max-width:90%" border="0" alt="PHP经典项目案例-(1)博客管理系统3" > </a></td> </tr> </table> </td> </tr>
这里给出上面用到的方法实现代码:
sqlHelper.class.php部分代码:
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->password, $this->dbname); if($this->mysqli->connect_error){ die("连接失败".$this->mysqli->connect_error); } $this->mysqli->query("set names utf8"); } //执行dql语句 public function execute_dql($sql){ $res = $this->mysqli->query($sql) or die($this->mysqli->error); //这里返回的是一个结果集,当调用$row = $res->fetch_assoc()时是一条一条的向下走,应该使用while循环 return $res; } <span style="font-family: Arial, Helvetica, sans-serif;">}</span>
dql语句就是简单的查询语句。
在使用数据库查询之前,先把这个文件包进去,然后new一个工具类对象,然后使用对象调用里面的函数。
3、最新图片显示
<!-- 最新图片显示 --><tr> <span style="white-space:pre"> </span><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" cellspacing="0" cellpadding="0" valign="top" style="margin-top:5px;"> <?php <span style="white-space:pre"> $sql="select id,tpmc,file from tb_tpsc order by id desc limit 2"; $res2 = $sqlHelper->execute_dql($sql); while($info=$res2->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><td width="9" rowspan="2" align="center"> </td> <td width="147" align="center"> <a href="image.php?recid=<?php%20echo%20%24info%5B'id'%5D;%20?>" target="_blank"> <img src="<?php%20echo%20%24data;?>" style="max-width:90%" style="max-width:90%" border="0" alt="PHP经典项目案例-(1)博客管理系统3" > </a> </td> <td width="10" rowspan="2" align="center"> </td> </tr> <tr> <td align="center">图片名称:<?php echo $info['tpmc'];?> </td> </tr> <?php } ?> <tr> <span style="white-space:pre"> </span><td colspan="3" height="10" align="right"><a href="pic_more.php"><img src="images/more.gif" style="max-width:90%" style="max-width:90%" border="0" alt="PHP经典项目案例-(1)博客管理系统3" > </a></td> </tr> </table> </td> </tr> </table> </td> </tr>
同样使用了数据库查询。
4、公告区实现
在公告区使用了我以前没有见过的一个标签
它里面设置了一些属性,就是当鼠标停留在上面的时候它就停止滚动,离开的时候就开始滚动。
<?php <span style="white-space:pre"> $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"> </center></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 }?></marquee>
到这里我们的首页基本就实现了。这是index.php 的完整代码:index.php提取码:iu09

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











많은 사용자들이 스마트 시계를 선택할 때 Huawei 브랜드를 선택하게 됩니다. 그 중 Huawei GT3pro와 GT4가 가장 인기 있는 선택입니다. 두 제품의 차이점을 궁금해하는 사용자가 많습니다. Huawei GT3pro와 GT4의 차이점은 무엇입니까? 1. 외관 GT4: 46mm와 41mm, 재질은 유리 거울 + 스테인레스 스틸 본체 + 고해상도 섬유 후면 쉘입니다. GT3pro: 46.6mm 및 42.9mm, 재질은 사파이어 유리 + 티타늄 본체/세라믹 본체 + 세라믹 백 쉘입니다. 2. 건강한 GT4: 최신 Huawei Truseen5.5+ 알고리즘을 사용하면 결과가 더 정확해집니다. GT3pro: ECG 심전도, 혈관 및 안전성 추가

Windows 11에서 캡처 도구가 작동하지 않는 이유 문제의 근본 원인을 이해하면 올바른 솔루션을 찾는 데 도움이 될 수 있습니다. 캡처 도구가 제대로 작동하지 않는 주요 이유는 다음과 같습니다. 초점 도우미가 켜져 있습니다. 이렇게 하면 캡처 도구가 열리지 않습니다. 손상된 응용 프로그램: 캡처 도구가 실행 시 충돌하는 경우 응용 프로그램이 손상되었을 수 있습니다. 오래된 그래픽 드라이버: 호환되지 않는 드라이버가 캡처 도구를 방해할 수 있습니다. 다른 응용 프로그램의 간섭: 실행 중인 다른 응용 프로그램이 캡처 도구와 충돌할 수 있습니다. 인증서가 만료되었습니다. 업그레이드 프로세스 중 오류로 인해 이 문제가 발생할 수 있습니다. 이 문제는 대부분의 사용자에게 적합하며 특별한 기술 지식이 필요하지 않습니다. 1. Windows 및 Microsoft Store 앱 업데이트

1부: 초기 문제 해결 단계 Apple 시스템 상태 확인: 복잡한 솔루션을 살펴보기 전에 기본 사항부터 시작해 보겠습니다. 문제는 귀하의 기기에 있는 것이 아닐 수도 있습니다. Apple 서버가 다운되었을 수도 있습니다. Apple의 시스템 상태 페이지를 방문하여 AppStore가 제대로 작동하는지 확인하세요. 문제가 있는 경우 Apple이 문제를 해결하기를 기다리는 것뿐입니다. 인터넷 연결 확인: "AppStore에 연결할 수 없음" 문제는 때때로 연결 불량으로 인해 발생할 수 있으므로 인터넷 연결이 안정적인지 확인하십시오. Wi-Fi와 모바일 데이터 간을 전환하거나 네트워크 설정을 재설정해 보세요(일반 > 재설정 > 네트워크 설정 재설정 > 설정). iOS 버전을 업데이트하세요.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

이 글은 Vue 소스 코드를 해석하는 데 도움이 될 것이며 이를 사용하여 Vue2의 다양한 옵션에서 속성에 액세스할 수 있는 이유를 소개하는 것이 모든 사람에게 도움이 되기를 바랍니다!

차이점은 다음과 같습니다. 1. div는 블록 수준 요소이고, 범위는 인라인 요소입니다. 2. div는 자동으로 한 줄을 차지하지만, 범위는 자동으로 줄 바꿈되지 않습니다. 3. div는 더 큰 구조와 레이아웃을 줄 바꿈하는 데 사용됩니다. 4. div는 다른 블록 수준 요소와 인라인 요소를 포함할 수 있고, 범위는 다른 인라인 요소를 포함할 수 있습니다.

Vue2의 이 포인팅 문제로 인해 동료가 버그로 인해 화살표 기능이 사용되어 해당 소품을 얻을 수 없게 되었습니다. 제가 그에게 소개했을 때 그는 그것을 몰랐고, 그래서 저는 일부러 프론트엔드 커뮤니케이션 그룹을 살펴보았습니다. 지금까지 적어도 70%의 프론트엔드 프로그래머들은 오늘 그것을 이해하지 못하고 있습니다. 모든 것이 불분명하다면 이 링크를 아직 배우지 않았다면 큰 소리로 말해주세요.

Watch4pro와 gt는 각각 서로 다른 기능과 적용 가능한 시나리오를 가지고 있습니다. 포괄적인 기능, 고성능, 세련된 외관에 중점을 두고 더 높은 가격을 감수할 의향이 있다면 Watch 4 Pro가 더 적합할 수 있습니다. 높은 기능 요구 사항이 없고 배터리 수명과 합리적인 가격에 더 많은 관심을 기울이는 경우 GT 시리즈가 더 적합할 수 있습니다. 최종 선택은 개인의 필요와 예산, 선호도에 따라 결정되어야 합니다. 자신의 필요를 잘 고려한 후 구매하고, 다양한 제품에 대한 리뷰와 비교를 참고하여 보다 현명한 선택을 하는 것이 좋습니다.
