Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I can't see the problem with this bit of code it seems simple enough, i have a basic webpage:
<?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" /> Unlock this page to continue!
<br />
<p class="link_ins">TEST</p>
<div id="_ostatus" style="color:#ffffff; font-size:14px; font-weight:normal"> </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="" /> <?php echo $row['offer_title']; ?></div>
</td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
<div id="dform" style="display:none; width:90%; text-align:center">
</form>
</div>
</div>
</div>
The URL is like this: http://www.site.co.uk/page.php?l=1p=7 what i'm trying to do is get the value of $_GET['p'] and use it within the foreach loop, when i try to print the value out within the loop it's blank but shows fine before it enters the loop, i have racked the brains i can't think of an alternate way of getting that value, any help would be appreciated.
Is your URL correct at your guess? Believably, what you are trying to do is: http://www.site.co.uk/page.php?l=1&p=7 Notice the & in the URL. You had: http://www.site.co.uk/page.php?l=1p=7. Was that intentional?
In your URL, the two query string parameters need to be separated by &. It's unable to recognize what p is.
http://www.site.co.uk/page.php?l=1&p=7
Related
So I'm trying to set the body background tag to a php variable I created, however I can't get it to correctly work.
Here is the simple PHP:
<?php
$backGround = "images/backgrounds/grey.png";
?>
and here is the HTML I tried which none worked.
<body background="<?php echo $backGround; ?>">
<body background="<?php echo htmlspecialchars($backGround); ?>">
I found these from preview stack overflow questions but they were about setting PHP variables to image sources. I would have thought it would apply to this as well.
Here's my entire PHP page using some of the suggestions but yet to still work.
<?php
$backGround = "images/backgrounds/grey.png";
?>
<html>
<head>
<title>Exodus</title>
<link rel=StyleSheet href="styles/main.css" type="text/css" media=screen>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Google Fonts -->
<link href='https://fonts.googleapis.com/css?family=Quicksand' rel='stylesheet' type='text/css'>
<!-- JS Scripts -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="assets/fader.js"></script>
</head>
<body style= 'background-image: url("<?php echo $backGround; ?>")'>
<div class="pre-wrap">
<div id="container">
<img src="images/logo.png" id="logo" alt="Pre Logo" style="display: none; margin: 0 auto;" />
</div>
</div>
<div class="wrap">
<p>Test</p>
</div>
</div>
</body>
First of all - using backgound attribute is not recommended by W3C.
What you really need is inline style:
<body style="background-image: url('<?php echo $backGround; ?>')">
check this it will work
<body style= 'background-image: url("<?php echo $backGround; ?>")'>
<body style= 'background-image: url("<?php echo htmlspecialchars($backGround); ?>")'>
I have a master page that uses ajax to load contents in a div named 'Wrapper'.
Now I have a problem loading jquery UI tabs this way. I can load and show them if I ignore using AJAX. But when Using ajax just the tabs are being shown and not the panes! I have read all the topics regarding this issue but they didn't solve my problem.
JQuery code is :
$(function(){
$('#link').live('click',function(){
$.ajax({
url: "tabs.php",
success: function(response)
{
$("#Wrapper").html(response);
console.log(response);
}
});
});
});
The tabs.php :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fa-ir" lang="fa-ir">
<head>
<script type="text/javascript" src="Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="Scripts/menu.js"></script>
<script type="text/javascript" src="Scripts/jquery.cycle.all.js"></script>
<script type="text/javascript" src="Scripts/jquery.easing.1.3.js"></script>
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.css" />
<script type="text/javascript" src="Scripts/jquery-ui-1.10.3.custom.js"></script>
<style>
div.panes div h2
{
margin:5px 0 15px 0;
}
</style>
<link rel="stylesheet" type="text/css" href="css/tabs.css"/>
<link rel="stylesheet" type="text/css" href="css/tabs-panes.css"/>
<style type="text/css">
div.panes div
{
-background:#fff;
height:auto;
}
div.panes label
{
margin-bottom:15px;
display:block;
}
label.error
{
color:red;
}
body
{
background-color:#d4d6da;
}
</style>
<link rel="stylesheet" type="text/css" href="css/mystyle.css">
<link rel="stylesheet" type="text/css" href="css/syntax.css"/>
<link rel="stylesheet" type="text/css" href="css/demos.css"/>
</head>
<body>
<table style="width:100%;height:auto;border:1px dashed blue;" >
<tr>
<td align="center">
<div id="wizard_tabs">
<!-- tabs -->
<ul class="tabs">
<li>1- File upload</li>
<li>2- Proj explanation</li>
</ul>
<!-- form and panes -->
<form action="projects-regEN.php" method="post" enctype="multipart/form-data">
<div class="panes" style="font-family:tahoma">
<div style="border:1px solid #1c94c4;" id="tabs-1">
<table id="projINFO" style="width:100%">
<tr>
<td>
<span class="innerStyle">Title</span>
</td>
<td>
<input type="text" style="width:150px" maxlength="50" id="projectTitle" name="projectTitle"/>
</td>
</tr>
<tr>
<td style="width:31%" >
<span class="innerStyle">Proj Upload</span>
</td>
<td style="width:30%">
<input type="file" id="projectUpload" name="projectUpload"/>
</td>
</tr>
</table>
<br/>
<input type="button" class="next" id="next" name="continue"/>
</div>
<div style="border:1px solid #1c94c4;" id="tabs-2">
<table style="width:100%;border:1px solid black;font-family:tahoma;font-size:11px">
<tr>
<th>
title
</th>
</tr>
<tr>
<td id="firstCol"></td>
</tr>
</table>
<br/>
<span class="innerStyle">explanation</span>
<textarea rows="4" maxlength="150" class="formItems" id="ProjInfo" name="ProjInfo" placeholder="پیام خود را اینجا وارد کنید"></textarea>
<input type="submit" id="submitproj" name="done"/>
</div>
</div>
</form>
</div>
<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
<script>
$(function(){
var wizard = $("#wizard_tabs");
$("ul.tabs", wizard).tabs("div.panes > div", function(event, index)
{
projUp=$("#projectUpload").val();
projTi=$("#projectTitle").val();
if (index > 0 && (projUp==''|| projTi=='' ))
{
$("#projectUpload").parent().addClass("error");
return false;
}
$("#projectUpload").parent().removeClass("error");
});
// get handle to the tabs API
var api = $("ul.tabs", wizard).data("tabs");
$(".next", wizard).click(function()
{
projUp=$("#projectUpload").val();
projTi=$("#projectTitle").val();
if(projUp!='' && projTi!='')
api.next();
});
});
</script>
</td>
</tr>
</table>
</body>
</html>
Using the papers I have read I tried initializing :
$("ul.tabs").tabs("div.panes <> div");
I put it in the success function of ajax but it didn't help. I also put it in the tabs.php but neither it helped. I don't know what else to do?!
Based on where I put the initial statement, it gives me different errors like:
"Uncaught Error:cannot call methods on tabs prior to initialization; attempted to call method 'div.panes > div'"
or
"Uncaught TypeError: Object [object Object] has no method 'tabs' "
Thanks
It looks like there is a small error (though maybe a typo for the question) in your code: <> should simply be >. Also, are you including every js file you need for tabs to work? The second error indicates that a required JS file/class may be missing.
For example, you may have included the jquery base, but did you include tools?
<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
EDIT: This works now thanks to ' olly_uk '
EDIT2: It works now, but the alignment of the boxes is wrong. You can view a screenshot HERE. Without any text it will align perfectly with 2 boxes on each line at a perfect distance from each other, but with text it echo's it under each other. Why?
I am trying to echo a image, then in that image I want to echo text from a database.
Well it echo's the images (3, because I only have 3 product examples in the database), but the products are not aligned in the boxes. It comes under it. I have searched on google but could not find anything
Is it even possible to use e.g. margin-top to move the posted echo so I could align it in the box?
I want to use style or class in the PHP...
Example image: IMAGE
adding <style>p{...};h3{...};</style> worked
Code sample
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>BOX</title>
<link href="includes/style.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
<style>
p {
position:relative;
top:-240px;
left:180px;
}
h3 {
position:relative;
top:-270px;
left:30px;
}
</style>
</head>
<?php
include 'includes/connection.php';
$query = "SELECT * FROM products";
$result = mysql_query($query);
?>
<body>
<div class="header navpos c1" id="nav">
<table summary="header" border="0">
<tr>
<td>
<ul>
<li class="home"></li>
</ul>
</td>
<td>
<ul>
<li class="about"></li>
</ul>
</td>
<td>
<ul>
<li class="contact"></li>
</ul>
</td>
<td>
<ul>
<li class="twitter"><img src="includes/images/f_logo.png" alt="** PLEASE DESCRIBE THIS IMAGE **" /></li>
</ul>
</td>
<td>
<ul>
<li class="facebook"><img src="includes/images/t_logo.png" alt="link to Syndicate Plus Twitter" /></li>
</ul>
</td>
</tr>
</table>
</div>
<div class="offers">
<div class="content_box">
<?php
while($products = mysql_fetch_array($result)) {
echo '<img src="includes/images/content_box.png" border=0 />';
echo "<h3>" . $products['products'] . "</h3>";
echo "<p>" . $products['description'] . "</p>";
}
?>
</div>
</div>
</body>
</html>
i think you could achieve this using CSS. by having a negative top to bump the text over the top of the image. will try to give some example code when i get home.
check this out in the mean time, w3schools CSS-positioning
hope that helped
EDIT: added code to show what i mean
<html>
<head>
<title>text over image</title>
<style>
p {
position:relative;
top:-200px;
}
h2 {
position:relative;
top:-140px;
}
</style>
<head>
<body>
<img src="/images/office1.jpg" alt="demo image"/>
<h2>test text</h2>
<p>test desciption text</p>
<hr/>
<img src="/images/office1.jpg" alt="demo image"/>
<h2>test text</h2>
<p>test desciption text</p>
</body>
I would like to kindly ask you to help me understand how does the view part "see" the layout part in the zend framework.
In my way of thinking(and I'm thinking like a noob) there should be a root that directs the view (index.phtml) to the layout (designer.phtml) right?
Below is not my code, I'm just trying to make sense of it.
This is the view part of the code, the root of the file is /applications/xampp/xamppfiles/htdocs/mts/applications/modules/designer/views/scripts/index/ index.phtml
<div style="width:100%; margin-bottom:20px; margin-top:5px;">
<span style="padding-left:10px; font-size:18px;">Designer <img alt="(?)" src="/style/images/help-8.png"/></span>
</div>
<?= $this->leftmenu; ?>
<div id="picFrame" style="text-align: center"></div>
<div id="middle_admin_content">
<fieldset>
<legend id="bookTitleLegend">Please select a book first</legend>
<div id="fileBox"><div id="innerBox"></div></div>
<div id="uploadSuccess" class="statusBox" style="display: none; background-color: #D9F5CB"><span>File Uploaded Successfully</span></div>
<div id="uploadFailed" class="statusBox" style="display: none; background-color: #EBB9B9"><span>File Upload Failed</span></div>
<div id="aboutTheBook" style="display: none">
<form id="aboutTheBookForm" action="" method="post">
<textarea name="about_the_book" id="about_the_book" cols="60" rows="10"></textarea>
<input type="submit" value="Save Text" name="saveCoverText"/>
<input type="hidden" value="" name="bookid" id="bookidField"/>
</form>
</div>
</fieldset>
</div>
This is the layout part of the code, the root of the file is
/applications/xampp/xamppfiles/htdocs/mts/applications/layouts/scripts/designer.phtml
<?php echo $this->doctype() ?>
<html>
<head>
<title>InTech - Design</title>
<?php
echo $this->headTitle() . "\n";
echo $this->headMeta() . "\n";
?>
<?
echo $this->headStyle() . "\n";
echo $this->headLink() . "\n";
echo $this->headScript(). "\n";
?>
<?
/*
$jsContainer = $this->Minify_Container();
$jsContainer->appendFile('/js/jquery-1.4.2.min.js');
$jsContainer->appendFile('/js/jquery-ui-1.8.2.custom.min.js');
$jsContainer->appendFile('/js/jquery.autocomplete.js');
$jsContainer->appendFile('/js/jquery.bgiframe.min.js');
$jsContainer->appendFile('/js/jquery.idTabs.min.js');
$jsContainer->appendFile('/js/jquery/jquery.form.js');
$jsContainer->appendFile('/js/uploadify/jquery.uploadify.v2.1.4.min.js');
$jsContainer->appendFile('/js/designer/designer.js');
$jsContainer->appendFile('/js/scrollpane/jquery.jscrollpane.min.js');
$jsContainer->appendFile('/js/scrollpane/jquery.mousewheel.js');
echo $this->Minify($jsContainer, 'js');
$cssContainer = $this->Minify_Container();
$cssContainer->appendStylesheet('style/ui.all.css');
$cssContainer->appendStylesheet('js/jquery-ui-1.8.2.custom.css');
$cssContainer->appendStylesheet('style/site_css/designer_style.css');
$cssContainer->appendStylesheet('js/scrollpane/jquery.jscrollpane.css');
echo $this->Minify($this->headLink(), 'css');
echo $this->Minify($cssContainer, 'css');
*
*/
?>
<!-- MINIFIED ABOVE ------------------------->
<link rel="shortcut icon" href="/style/site_images/favicon.ico" type="image/x-icon" />
<link type="text/css" href="/style/ui.all.css" rel="stylesheet" />
<link type="text/css" href="/js/jquery-ui-1.8.2.custom.css" rel="stylesheet" />
<link type="text/css" href="/style/site_css/designer_style.css" rel="stylesheet" />
<link type="text/css" href="/js/scrollpane/jquery.jscrollpane.css" rel="stylesheet" />
<!--<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>-->
<script type="text/javascript" src="/assets/modules/manager/basic/js/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="/assets/modules/manager/basic/js/plugins/jquery.form.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript" src="/js/jquery.autocomplete.js"></script>
<script type="text/javascript" src="/js/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="/js/jquery.idTabs.min.js"></script>
<!--<script type="text/javascript" src="/js/jquery/jquery.form.js"></script>-->
<script type="text/javascript" src="/js/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript" src="/js/designer/designer.js"></script>
<script type="text/javascript" src="/js/scrollpane/jquery.jscrollpane.min.js"></script>
<script type="text/javascript" src="/js/scrollpane/jquery.mousewheel.js"></script>
<!-- -->
</head>
<body>
<div id="dialog" style="display:none; font-size:12px; background-color:#ffffff;">
<div id="dialog_left" style="float:left; width:150px">
</div>
<div id="dialog_right">
</div>
</div>
<div id="dialogDelete" style="display: none">Delete Item?</div>
<!-- HEADER SITE AREA :: START -->
<div id="header">
<?php
$front = Zend_Controller_Front::getInstance();
$module = $front->getRequest()->getModuleName();
echo $this->render('header-designer.phtml', array(
'authenticated' => $this->authenticated
));
?>
</div>
<!-- HEADER SITE AREA :: END -->
<!-- CONTENT :: START -->
<div id="contentAdmin">
<div id="helpDialog" style="display: none"></div>
<?php echo $this->layout()->content ?>
</div>
<!-- CONTENT :: END -->
<!-- FOOTER SITE AREA :: START -->
<div id="footer">
<?php echo $this->render('footer.phtml', array(
'authenticated' => $this->authenticated
)) ?>
</div>
<!-- FOOTER SITE AREA :: START -->
</body>
</html>
The specific mechanics of how all this implemented involves bootstrapping application resources and registering late-running front-controller plugins.
But the short answer is the "system" knows how to find/render the view-script associated to the requested action and how to find/render your layout script with the view-script content injected.
Remember, at some point, you bootstrapped a Layout resource, probably in configs/application.ini.
You also bootstrapped a View resource - either explicitly or implicitly - which knows how to render your headTitle(), headMeta(), headScript(), etc (all rendered using view-helpers), as well as the layout.
So, there's really no mystery that the "system" is aware of all this stuff.
In master.php
<?php
//echo "session check: ".$_SESSION['session_array'];
//exit;
session_start(); // Session Starts
if( !isset($_SESSION['session_array']) )
{
header("Location: index.php");
exit;
}
include("conn.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LMS</title>
<link rel="stylesheet" type="text/css" href="jui/themes/gray/easyui.css">
<link rel="stylesheet" type="text/css" href="jui/general.css">
<link rel="stylesheet" type="text/css" href="jui/themes/icon.css">
<script type="text/javascript" src="jui/jquery-1.6.min.js"></script>
<script type="text/javascript" src="jui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<script type="text/javascript" src="js/date.js"></script>
<script type="text/javascript" src="js/core.js"></script>
</head>
<body class="easyui-layout">
<div region="north" class="north_master" border="false" split="false" >
<div style="float:left;">
<img src="images/usr_logo.jpg" alt="Lead Management System" width="168" height="66" title="Lead Management System" >
</div>
<div style="float:right;">
<br/><br/>
<a id="logout" name="logout" href="logout.php?logout=1" class="easyui-linkbutton" iconCls="icon-cancel" onClick="javascript: return confirm('Are you sure you want to log out?');">Logout</a>
</div>
</div>
<div region="south" class="south" border="false">
<?php include('footer.php'); ?>
</div>
<div region="center" class="center" style="background-image:url(img/product-display.jpg);background-repeat:no-repeat;background-attachment:fixed;background-position:right bottom; ">
<?php
include('dashboard.php');
?>
</div>
</body>
</html>
In dashboard.php
<script language="javascript">
jQuery(document).ready(function($){
alert("check");
});
</script>
<div class="content">
<h1>Slot Dashboard</h1>
<div>
Add Slot
</div>
<table border='1' bordercolor='#B4B4B4' cellpadding='1' cellspacing='0' width='80%' align="center">
<tr align="left">
<th>Week</th>
<th>Dates</th>
<th>Status</th>
<th>Date</th>
<th>Action</th>
</tr>
<tr>
<td>1</td>
<td>09/04/2011 - 09/10/2011</td>
<td>Revised</td>
<td>09/04/2011</td>
<td>View</td>
</tr>
<tr>
<td>2</td>
<td>09/11/2011 - 09/17/2011</td>
<td>Revised</td>
<td>09/11/2011</td>
<td>View</td>
</tr>
<tr>
<td>3</td>
<td>09/18/2011 - 09/24/2011</td>
<td>Not Submitted</td>
<td>09/18/2011</td>
<td>View</td>
</tr>
</table>
</div>
Question: While master.php runs "check" alerts twice.
I need to know why "check" alerts twice. How to solve this
<div region=center>
The scripts within the div runs twice. there is some bug with jeasy-ui. Help me how to solve that.
Technically included page alert shouldn't fire twice. it is only possible in case of you add sample.php file in php.ini as auto_append_file
i found same problem in easyui every version, when script is included in to panel/layout, the script will be run twice, the reason I think:
the page be loaded in browser ,the browser run the script of page once, when dom is loaded ,the easyui render style for the node in dom, the script in the node will be called second by easyui.
this problem isn't only in layout , but in panel, Maybe even for the every thing inherit from panel.
this problem may be in the easyui's root render method, so I can't find solved for this without src.
now i have to change easyui to another ui framework.
example for theis problem, the alert be called twice in browser:
</div>
<div region="south" class="south" border="false">
</div>
<div region="center" class="center" >
<script>
alert("here");
</script>
</div>