2016-06-08 11 views
-3

Ich kann nicht das Problem mit diesem Stück Code sehen scheint es einfach genug, ich habe eine grundlegende Webseite:

<?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> 

Die URL ist wie folgt: http://www.site.co.uk/page.php?l=1p=7 was ich bin versuchen zu tun ist, den Wert von $ _GET ['p'] zu erhalten und es innerhalb der foreach-Schleife zu verwenden, wenn ich versuche, den Wert innerhalb der Schleife auszudrucken, die es leer ist, aber vor dem Eintritt in die Schleife gut zeigt, habe ich die Gehirne zertrümmert Ich kann mir keinen alternativen Weg vorstellen, diesen Wert zu bekommen, jede Hilfe wäre willkommen.

+0

so ist, wo '$ _GET [ 'l']' und '$ _GET [ '1P']'? Alles was ich sehe ist '$ _GET ['p']'. –

+0

Bitte zeigen Sie die Ausgabe 'print_r ($ _ GET)' – Naumov

+1

Ist die URL falsch eingegeben? Sie haben kein kaufmännisches Und trennen l und p. Sollte es http://www.site.co.uk/page.php?l=1&p=7 sein. Andernfalls existiert $ _GET ['p'] nicht. – Robbert

Antwort

1

Ist Ihre URL korrekt? Glaubwürdig, was Sie versuchen zu tun ist: http://www.site.co.uk/page.php?l=1&p=7 Beachten Sie die & in der URL. Sie hatten: http://www.site.co.uk/page.php?l=1p=7. War das absichtlich?

Verwandte Themen