Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php-使用存储在DB表格字段中的值更改表格背景颜色?_Php_Background Color - Fatal编程技术网

php-使用存储在DB表格字段中的值更改表格背景颜色?

php-使用存储在DB表格字段中的值更改表格背景颜色?,php,background-color,Php,Background Color,更新。表id样式: #card { position:absolute; border-spacing:0; border-collapse:collapse; background-color:#6e97db; height:720px; width:100%; } 编辑 HTML来源: <!doctype html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet"

更新。表id样式:

#card {
position:absolute;
border-spacing:0;
border-collapse:collapse;
background-color:#6e97db;
height:720px;
width:100%;
}
编辑

HTML来源:

<!doctype html>
<html>
<head>
<meta charset="utf-8">

<link rel="stylesheet" href="styles/all.css" />
<link rel="stylesheet" href="styles/formbacks.css" />
<link rel="stylesheet" href="styles/slideshow.css" />

<script type="text/javascript" src="js/jquery-2.1.1.js"></script>

<link href='//fonts.googleapis.com/css?family=Economica:700,400italic' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Voltaire' rel='stylesheet' type='text/css'>

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />

<title>Trading Card Generator</title>
<meta name="Description" content="Trading Card Generator - Create Your Own Comics, Predators & Tennis Trading Cards" />
<meta name="Keywords" content="Trading Card Generator, trading card maker, top trumps trading cards" />

<script>
$(function(){
$(document).click(function(){  
$('.messagebox').hide();
});
});
</script>

<style> 
@font-face {
font-family:TCG;
src: url(xirod.ttf);
}

@font-face {
font-family:TCGHEADING;
src: url(GearsOfPeace.ttf);
}

@font-face {
font-family:TCGAUTHOR;
src: url(kenyancoffeerg.ttf);
}

@font-face {
font-family:TCGPN;
src: url(GearsOfPeace.ttf);
}

div {font-family:TCG;}
div {font-family:TCGHEADING;}
div {font-family:TCGAUTHOR;}
div {font-family:TCGPN;}
</style>

</head>

<body id="bodyform">

<p class="header"><a href="index.php">Trading Card Generator</a></p>

<p class="disclaimer">DC vs Marvel&nbsp;<br />
Card Back Face<br />
This is a non profit website.</p>

<ul id="navigation">
<li><a href="#">create</a><ul>
<li><a href="backfacecreate.php">back face</a></li>
<li><a href="bcardscreate.php">business</a></li>
<li><a href="comicscreate.php">comics</a></li>
<li><a href="predatorscreate.php">predators</a></li>
<li><a href="tenniscreate.php">tennis</a></li>
</ul></li>
<li><a href="#">edit</a><ul>
<li><a href="backfaceedit.php">back face</a></li>
<li><a href="bcardsedit.php">business</a></li>
<li><a href="comicsedit.php">comics</a></li>
<li><a href="predatorsedit.php">predators</a></li>
<li><a href="tennisedit.php">tennis</a></li>
</ul></li>
<li><a href="register.php">register</a><ul>
</ul></li>
<li><a href="#">themes</a><ul>
<li><a href="backfacedisplay.php">back face</a></li>
<li><a href="bcardsdisplay.php">business</a></li>
<li><a href="comicsdisplay.php">comics</a></li>
<li><a href="predatorsdisplay.php">predators</a></li>
<li><a href="tennisdisplay.php">tennis</a></li>
</ul></li>
<li><a href="logout.php">logout</a></li>
<li><a href="contact.html">contact</a></li>
</ul>

<div class="previouscard"></div>

<div class="bouncein">

<table id="card">
<tr>
<td style="background-color:#211e1e"></td>
</tr>
<tr>
<td><p class="tcg">Trading Card Generator</p></td>
</tr>
<tr>
<td class="tcgnamecell">DC vs Marvel<br/> Heroes &amp; Villains</td>
</tr>
<tr>
<td class="tcgimagecell"><img class="imgsize" alt="" src="uploads/Darkseid.png" /></td>
</tr>
<tr>
<td><p class="author">Created by M B Mehdi</p></td>
</tr>
</table>
</div>

<div class="nextcard"></div>
<div class="currentcard">Card 1 of 1</div><br><br>
<div class="currentcard"><a id="carddownload" href="#card" class="downloadbtn">Download</a></div>
</div>

<div id='loader'><img src="images/ajax-loader.gif" alt="loader"/></div>
<script type="text/javascript" src="js/html2canvas.js"></script>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
var $loading = $('#loader').hide();
$('#carddownload').on('click', function() {
showimage(); 
});
$(document)
.ajaxStart(function () {
$loading.show();
})
.ajaxStop(function () {
$loading.hide();
});
function showimage(){
html2canvas([document.getElementById('card')], {
onrendered: function(canvas)
{
var img = canvas.toDataURL()
$.post("save.php", {data: img}, function (file) {
window.location.href ="downloadbusinesscard.php?path="+ file}); 
}
});
}
</script>
</body>
</html>
然后将它们显示回表格中的用户,但当我回显背景颜色时,它不会显示,并且css中默认设置的背景颜色仍然保留:

<table id="card">
<tr>
<td style="background:<?php echo $bgcolour[$i]; ?>">
</tr>
<tr>
<td><p class="tcg">Trading Card Generator</p></td>
</tr>
<tr>
<td class="tcgnamecell"><?php echo $theme[$i]."<br/> ".$subheading[$i];?></td>
</tr>
<tr>
<td class="tcgimagecell"><?php echo '<img class="imgsize" alt="" src="'.$img_paths[$i].'" />'; ?></td>
</tr>
<tr>
<td><p class="author">Created by <?php echo $author[$i];?></p></td>
</tr>
</table>

创建人

试试看


我相信问题在于你的CSS表单胜过了你的Style=”“代码。可以肯定的是,添加以下内容:

style="background:<?php echo $bgcolour[$i]; ?> !important"
style=“背景:!重要”

假设此处显示的代码是实际代码,则该代码无效

<td style="background:<?php echo $bgcolour[$i]; ?>">

谢谢大家的帮助。我应该列出表id样式,并解释我使用它来设置样式,而不是td元素

<table id="card" style="background-color:<?php echo $bgcolour[$i]; ?>">

不起作用。是,存储了#。在db中的BGCOLOR字段中,我有以下条目#2111E1E。您能将实际输出的HTML示例发布到浏览器吗?这与我在开场白中列出的一样,不包括导航。这个特定的页面需要登录,但您可以通过查看一个不需要登录的页面来了解HTML。结构有所不同,因为此处有更多元素,但数据仍显示在表中:链接页面没有任何具有样式属性的单元格。为了帮助您,我们需要看到的正是您的脚本输出的HTML。我不确定如何使用实时服务器端代码转储HTML。@MBM$bgcoloeur[$I]的输出是什么??您能否在您的postvar_转储中包含一个示例($BGCOLOR);给出数组(1){[0]=>string(7)“#2111E1E”},因此它正在获取值。@MGM-worde。。。您确定$i仍然在数组的范围内吗?是的,因为我对其他表中的其他字段使用相同的结构,它们工作正常。如果我这样做,这里的文本将以存储在字段中的十六进制颜色显示,但我无法使其覆盖执行该操作的表的默认背景颜色!但是table id类决定颜色和其他元素,而不是td元素。我已经解决了这个问题,因此@MGM做了一个
print\r($bgcolour)
并将结果发布到这里,这样我们就可以看到$BGcolor的内容了,我已经尝试过了。事实上,如果我在css中禁用背景颜色,它仍然不会选择颜色。请在浏览器中为特定行发布输出代码。style=“”中必须存在错误
style="background:<?php echo $bgcolour[$i]; ?> !important"
<td style="background:<?php echo $bgcolour[$i]; ?>">
</td>
 <td style="background:<?php echo $bgcolour[$i]; ?>"></td>
<table id="card" style="background-color:<?php echo $bgcolour[$i]; ?>">