获得环

获得环

问题描述:

内$ _GET值我看不出问题,这段代码似乎很简单,我有一个基本的网页:获得环

<?php 

include('includes/db_connection.php'); 
include('includes/functions.php'); 
include('includes/arrays.php'); 

?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Payday Dreams</title> 
<link href='http://fonts.googleapis.com/css?family=Nunito:400,300,700' rel='stylesheet' type='text/css'> 
<link href="templates/css/main.css" rel="stylesheet" type="text/css" /> 
<link href="templates/css/bootstrap_v3.css" rel="stylesheet" type="text/css" /> 
<style type="text/css"> 
body{background:url(templates/images/bg_sub.png) repeat-x;} 
</style> 
<script type="text/javascript" src="templates/js/jquery.js"></script> 
<script type="text/javascript" src="templates/js/bootstrap.js"></script> 
<script type="text/javascript" src="templates/js/json2.js"></script> 
<script type="text/javascript" src="templates/js/common.js"></script> 
<script type="text/javascript" src="templates/js/ajax.js"></script> 
</head> 
<body style="background:#cfe4ee;"> 
<div style="height:100px; background:#000;"> 
<div style="width:971px; margin:0 auto; color:#ffffff; font-size:13px;"> 
<div style="text-align:center; padding-top:10px; font-size:16px; font-weight:bold; font-family:Arial"> <img src="templates/images/small_lock.png" alt="" style="vertical-align:middle" />&nbsp;Unlock this page to continue! 
<br /> 
<p class="link_ins">TEST</p> 
<div id="_ostatus" style="color:#ffffff; font-size:14px; font-weight:normal">&nbsp;</div> 
</div> 
</div> 
</div> 
<div id="linklocker_wrapper"> 
<div id="contents" style="margin-top:100px;"> 
<div class="jumbotron"> 
<div id="offersSection2" style="height:250px; width:570px; margin:25px auto" > 

<!-- offer box --> 
<div class="offerp_box3" > 
<div class="mid" style="height:220px"> 
<div id="_offers"> 
<table class="table table-hover table-bordered table-condensed" style="width:530px; background:#ffffff; border:1px solid #cccccc;"> 
<?php 
    // get offers from the database 
    $rows = DB::getInstance()->select('SELECT * FROM `offers` ORDER BY RAND() LIMIT 5'); 
?> 
<?php foreach ($rows as $row) { ?> 
<?php 
print_r($_GET); 
$p = $_GET['p']; 
echo $p; 
?> 
    <tr > 
     <td class="offerDiv" title="<?php echo $row['offer_title']; ?>" style="height:30px; vertical-align:middle"> 
     <div><img src="templates/images/chk.png" alt="" />&nbsp;&nbsp;<a href="click.php?c=<?php echo $row['offer_title_id']; ?>&l=&p=<?php echo $p; ?>" target="_blank"><?php echo $row['offer_title']; ?></a></div> 
     </td> 
    </tr> 
<?php } ?> 
</table> 
</div> 
</div> 
</div> 

<div id="dform" style="display:none; width:90%; text-align:center"> 
</form> 
</div> 
</div> 
</div> 

的URL是这样的:http://www.site.co.uk/page.php?l=1p=7就是我试图做的是获取$ _GET ['p']的值并在foreach循环中使用它,当我尝试在循环内打印出它的值时,它是空白的,但在进入循环之前显示正常,我绞尽脑汁我无法想到获得该价值的替代方式,任何帮助将不胜感激。

+0

所以这里的'$ _GET [ 'L']'和'$ _GET [1P']'?我看到的只有'$ _GET ['p']'。 –

+0

请向您展示输出'print_r($ _ GET)' – Naumov

+1

网址输入有误吗?你没有和符号分开l和p。它应该是http://www.site.co.uk/page.php?l=1&p=7。否则,$ _GET ['p']不存在。 – Robbert

您的网址是否正确?可以想象,你要做的是:http://www.site.co.uk/page.php?l=1&p=7请注意URL中的&。你有:http://www.site.co.uk/page.php?l=1p=7。那是故意的吗?

在您的URL中,两个查询字符串参数需要用&分隔。它无法识别p是什么。

http://www.site.co.uk/page.php?l=1&p=7