search
HomeBackend DevelopmentPHP Tutorial这个变量是如何来的

这个变量是怎么来的

本帖最后由 lyhjc_2015 于 2014-11-21 09:02:41 编辑
下面这段代码中if(isset($_GET['n_page'])){                         //判断当前页码
n_page是从哪来的,我查了一下不是数据表中的字段,它到底是怎么来的,难道是随便定义的一个玩意吗
<?php<br />session_start();<br />include_once("conn/conn.php");<br />?><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html xmlns="http://www.w3.org/1999/xhtml"><br /><head><br /><link href="css/viewmeeting.css" type="text/css" rel="stylesheet" /><br /><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><br /><title>无标题文档</title><br /></head><br /><br /><body><br /><h3 id="会议信息浏览">会议信息浏览</h3><br /><br /><?php<br />$sqlview="select * from tb_meeting_info";<br />$num=2;                                                 //每页显示最大记录数<br />  if(isset($_GET['n_page'])){	                        //判断当前页码<br />   $c_page = $_GET['n_page'];					            //将$n_page赋给变量$c_apge<br />  }else{<br />		$c_page = 1;								    //初始化变量$c_page<br />	    }<br /> $l_rst = $conn -> PageExecute($sqlview,$num,$c_page);	//执行pageExecute函数<br />$rst_view = $conn->execute($sqlview);<br />$record=count($rst_view->GetRows());                    //获取总记录数<br />if($record==0){<br />echo "<span class=\"norecord\">当前没有任何记录</span>";<br />}else{<br />?><br /><br /><table width="728" border="0" cellspacing="0" cellpadding="0" bordercolor="#66CC00"><br />  <tr class="tableheader"><br />    <td width="55" align="center" height="25">会议编号</td><br />    <td width="60" align="center">会议名称</td><br />    <td width="60" align="center">部门名称</td><br />    <td width="80" align="center">会议地点</td><br />    <td width="80" align="center">会议日期</td><br />    <td width="45" align="center">主持人</td><br />    <td width="60" align="center">出席人员</td><br />    <td width="45" align="center">记录人</td><br />    <td width="120" align="center">会议摘要</td><br />	<td width="60" align="center">查看详情</td><br />  </tr><br /><?php<br />while(!$l_rst->EOF){<br />?><br /><br />  <tr><br />    <td height="30"><?php echo $l_rst->fields[0]; ?></td><br />    <td height="30"><?php echo $l_rst->fields[1]; ?></td><br />    <td height="30"><?php echo $l_rst->fields[2]; ?></td><br />    <td height="30"><?php echo $l_rst->fields[3]; ?></td><br />    <td height="30"><?php echo $l_rst->fields[4]; ?></td><br />    <td height="30"><?php echo $l_rst->fields[5]; ?></td><br />    <td height="30"><?php echo $l_rst->fields[6]; ?></td><br />    <td height="30"><?php echo $l_rst->fields[7]; ?></td><br />    <td height="30"><?php echo $l_rst->fields[8]; ?></td><br />	<td height="30" align="center"><a href="#" onclick="javascript:Wopen=open('showinfo.php?id=<?php echo $l_rst->fields[0]; ?>','','height=720,width=1004,scrollbars=no');"><img src="/static/imghwm/default1.png"  data-src="images/xiazai.gif"  class="lazy"      style="max-width:90%"  style="max-width:90%" border="0" alt="详情"></a></td><br />  </tr><br /><?php<br />   $l_rst->movenext();<br />   }<br /><br /> ?><br /></table><br /><div class="sepa_page"><br /><table><br />  <tr><br />    <td><br />  <font color='#999999'>当前是第<?php echo $l_rst -> absolutePage(); ?>页/一共<?php echo $l_rst -> LastPageNo(); ?>页</font><br /><?php<br /><br /><br />		if(!$l_rst -> AtfirstPage()){					//如果当前页不是首页<br />?><br /><br /><br /><br /><!--  输出向上翻页超链接  --><br />		<a href ="<?php echo "?lmbs=$_GET[lmbs]&n_page=1" ?>"> 首页 </a><br />		<a href ="<?php echo "?lmbs=$_GET[lmbs]&n_page=".($l_rst -> absolutePage() - 1); ?>"> 上一页 </a><br /><!--  ----------------------------  --><br /><?php<br />		}<br />		if(!$l_rst -> AtlastPage()){					//如果当前页不是尾页<br />?><br /><!--  输出向下翻页超链接  --><br />		<a href = "<?php echo "?lmbs=$_GET[lmbs]&n_page=".($l_rst -> absolutePage() + 1); ?>"> 下一页 </a><br />		<a href ="<?php echo "?lmbs=$_GET[lmbs]&n_page=".($l_rst -> LastPageNo());?>"> 尾页 </a>	<br /><!--  -----------------------------  --><br /><br /><?php<br />		}<br />?><?php<br />}<br />?><br />      </td><br />	  <td width="100" align="right"><span style="color:#FF0000">点此导出报表>>></span></td><br />	  <td width="60"><br />		   <a href="createform.php"><img  src="/static/imghwm/default1.png"  data-src="images/out_15.jpg"  class="lazy"  align="bottom"    style="max-width:90%"  style="max-width:90%" border="0" / alt="这个变量是如何来的" ></a><br />		</td><br />	 </tr><br />  </table><br /></div><br /></body><br /></html><br />

------解决思路----------------------
其实是由"> 首页 来的
这涉及到url传值的知识,当一个链接传到地址栏的时候$_GET[ ]数组就会截取它,因为$_GET[ ]数组是全局变量数组,专门负责截获地址栏中的值的。
只可惜大家都没有答对,上面是我悟出来的。
Statement
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
How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

Simple Guide: Sending Email with PHP ScriptSimple Guide: Sending Email with PHP ScriptMay 12, 2025 am 12:02 AM

PHPisusedforsendingemailsduetoitsbuilt-inmail()functionandsupportivelibrarieslikePHPMailerandSwiftMailer.1)Usethemail()functionforbasicemails,butithaslimitations.2)EmployPHPMailerforadvancedfeatureslikeHTMLemailsandattachments.3)Improvedeliverability

PHP Performance: Identifying and Fixing BottlenecksPHP Performance: Identifying and Fixing BottlenecksMay 11, 2025 am 12:13 AM

PHP performance bottlenecks can be solved through the following steps: 1) Use Xdebug or Blackfire for performance analysis to find out the problem; 2) Optimize database queries and use caches, such as APCu; 3) Use efficient functions such as array_filter to optimize array operations; 4) Configure OPcache for bytecode cache; 5) Optimize the front-end, such as reducing HTTP requests and optimizing pictures; 6) Continuously monitor and optimize performance. Through these methods, the performance of PHP applications can be significantly improved.

Dependency Injection for PHP: a quick summaryDependency Injection for PHP: a quick summaryMay 11, 2025 am 12:09 AM

DependencyInjection(DI)inPHPisadesignpatternthatmanagesandreducesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itallowspassingdependencieslikedatabaseconnectionstoclassesasparameters,facilitatingeasiertestingandscalability.

Increase PHP Performance: Caching Strategies & TechniquesIncrease PHP Performance: Caching Strategies & TechniquesMay 11, 2025 am 12:08 AM

CachingimprovesPHPperformancebystoringresultsofcomputationsorqueriesforquickretrieval,reducingserverloadandenhancingresponsetimes.Effectivestrategiesinclude:1)Opcodecaching,whichstorescompiledPHPscriptsinmemorytoskipcompilation;2)DatacachingusingMemc

See all articles

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 Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool