ページの上部に、データベースからデフォルトの css 値を読み取る PHP があります。
$query = "
SELECT
width,
height,
fontFamily,
fontSize,
color,
backgroundColor,
lineHeight,
marginTop,
marginLeft,
textAlign,
borderColor,
borderWidth,
boxShadow,
borderRadius,
last_url_published,
color1,
color2,
color3,
color4,
color5,
color6
FROM
users
WHERE
id = :id
";
$query_params = array (
':id' => $_SESSION['user']['id']
);
// echo("<br />index.php: query for defaults is: $query");
try
{
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch(PDOException $ex)
{
die("index.php line " . __LINE__ . ". Failed to read defaults from users table: " . $ex->getMessage());
}
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$row = $stmt->fetch();
extract($row); // produces $width, etc.
// echo("<br />killing time here");
私が持っているHTMLで
<body>
.cell_db {
width: <?=$width?>;
height: <?=$height?>;
background-color: <?=$backgroundColor?>;
border-color: <?=$borderColor?>;
border-width: <?=$borderWidth?>;
border-radius:<?=$borderRadius?>;
box-shadow:<?=$boxShadow?>
}
私が見ているのは、
echo("<br />killing time here");
たとえば、extract($row) からの $width 値は、css 行がによって評価されるとき、明らかに準備ができていませんPHP。ただし、echo ステートメントからの遅延を挿入すると、必要な時間が提供されます。ここで何が起こっているのか、どうすればこれを機能させることができるのかを誰かが理解していますか?
ありがとう
補遺:
以下の人々は、PHP から HTML までのすべてのコードを表示するよう求めたので、ここに示します。
<?php
//phpinfo();
ini_set('display_errors', 1);
error_reporting(E_ALL);
include ('functions.php'); // so we can call our showarray()
// First we execute our common code to connect to the database and start the session
require("common.php");
// showarray($_SESSION, "index.php, line " . __LINE__ . " SESSION Data:");
$_SESSION['landingPage'] = $_SERVER['PHP_SELF']; // login will redirect to here, either index.php or indexX.php, after password matches
// At the top of the page we check to see whether the user is logged in or not.
if(empty($_SESSION['user']))
{
// If they are not, we redirect them to the login page.
header("Location: login.php");
// Remember that this die statement is absolutely critical. Without it,
// people can view your members-only content without logging in.
die("Redirecting to login.php");
}
// get box default style for this user from the database
// update default styles
$query = "
SELECT
width,
height,
fontFamily,
fontSize,
color,
backgroundColor,
lineHeight,
marginTop,
marginLeft,
textAlign,
borderColor,
borderWidth,
boxShadow,
borderRadius,
last_url_published,
color1,
color2,
color3,
color4,
color5,
color6
FROM
users
WHERE
id = :id
";
$query_params = array (
':id' => $_SESSION['user']['id']
);
// echo("<br />index.php: query for defaults is: $query");
try
{
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch(PDOException $ex)
{
die("index.php line " . __LINE__ . ". Failed to read defaults from users table: " . $ex->getMessage());
}
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$row = $stmt->fetch();
extract($row); // produces $width, etc.
sleep(1);
// echo("<br />killing time here");
// open_color picker - in color.js
// open color panel - in color.js
?>
<!doctype html>
<!-- HTML5 -->
<html>
<head>
<meta charset="utf-8">
<title>MyWebsheet</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
<script src="js/GLOBALS.js"></script> <!-- Load these before editbox.js and color.js so they can see them when compiled -->
<script src="js/weebly_editbox.js"></script>
<script src="js/color.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript" src="js/jquery.Jcrop.js"></script>
<script src="http://www.mapquestapi.com/sdk/js/v7.0.s/mqa.toolkit.js?key= Fmjtd%7Cluub2h0z21%2C7a%3Do5-9utaqr"></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<!-- <link rel="stylesheet" type="text/css" href="CSS/reset.css" /> -->
<link rel="stylesheet" type="text/css" href="CSS/jquery.Jcrop.css" />
<!-- ***************************************************************************************************** -->
<!-- STYLES -->
<!-- ***************************************************************************************************** -->
<style type="text/css">
/* style top */
body { /* style wings wings style body color*/
height:4000px;
background-color:<?php echo ($_SERVER['PHP_SELF'] == '/indexX.php'? 'white' : '#165E3D')?>;
background-color:#fff;
background-color:#d44; /* change to make sure a new index.php is being uploaded */
margin:0;
padding:0px; /* keeps everything 10px away from walls */
}
/*
a {
cursor : pointer;
} */
p {
/* margin-top: 10px; */
}
#wrapper {
width:1024px;
height:800px;
position: absolute;
left:50%; /* puts left edge of wrapper at mid-point of viewport */
margin-left: -512px; /* shifts wrapper left half of its width */
background-color:transparent;
}
.cell_base {
position:absolute;
z-index:3;
border-style: solid;
display:none;
}
.cell_db {
width: <?=$row['width']?>;
height: <?=$row['height']?>;
background-color: <?=$backgroundColor?>;
border-color: <?=$borderColor?>;
border-width: <?=$borderWidth?>;
border-radius:<?=$borderRadius?>;
box-shadow:<?=$boxShadow?>
}
.cellContent_db {
font-family: <?=$fontFamily?> ;
margin-top: <?=$marginTop?>;
margin-left: <?=$marginLeft?>;
font-size: <?=$fontSize?>;
color: <?=$color?>;
line-height: <?=$lineHeight?>;
text-align: <?=$textAlign?>;
}