我对“高级PHP”很新颖,并且遇到PHP头文件错误。已经发送了PHP头文件
<?php
$getTrans = dbquery("SELECT * FROM cms_transactions WHERE userid = '".USER_ID."' AND pin = '0' ORDER BY date DESC LIMIT 50");
$oe = 1;
while($transaction = mysql_fetch_assoc($getTrans)){
if ($oe == 2)
{
$oe = 1;
}
else
{
$oe = 2;
}
$oDate = strtotime($transaction['date']);
$sDate = date("<b>l, j - F, o</b> g:ha",$oDate);
echo'
<tr style=" background-color: ' . (($oe == 2) ? '#e2e2e2' : '#fff') . ';">
<td>'.$transaction['id'].'</td>
<td>'.$transaction['descr'].'</td>
<td>'.$transaction['credits'].' deducted</td>
<td>'.$transaction['amount'].' deducted</td>
<td>'.$transaction['vip_points'].' deducted</td>
<td>'.$sDate.'</td>
<td><input type="submit" value="+ Pin" name="'.$transaction['id'].'" /></td>
</tr>
';
$trans = $transaction['id'];
if(isset($_POST["$trans"])){
dbquery("UPDATE cms_transactions SET pin = '1' WHERE id = '".$trans."' AND userid = '".USER_ID."' LIMIT 1");
header("Location: ".WWW."/identity/transactions");
}
}
if(mysql_num_rows($getTrans) == 0){
echo '<div class="error" id="black">You have no recent Transactions</div>';
}
?>
我在/身份证/交易的底部不断收到PHP头错误。
我意识到我得到的问题是因为“页面已经加载内容”,并且必须在页面的开头使用PHP页眉。 我发布的以下片段是包含的文件;在主文件中。
主要问题是,我正在寻找一种方法将内容从“后端”php工作中分离出来。
因此,例如:
主要PHP文件具有的全部代码,和包括();文件具有“内容”方面。
这有可能吗?如果你能举一个例子,那会很棒!
请让我知道,如果有什么不清楚给你。
编辑;这是整个文件:
<table class="information-table" style="margin-top:-5px;">
<tr>
<td style="text-shadow:none;">
<a class="new-button" href="<?php echo WWW ; ?>/account/logout"><b>Log out</b><i></i></a>
<div id="back-link" style="color:#fff;">
<a href="<?php echo WWW ; ?>/identity/avatars" style="color:#fff;">My Avatars</a> » <a href="<?php echo WWW ; ?>/identity/settings" style="color:#fff;">Account Settings</a> » Transactions
</div>
</td></tr>
</table>
<div id="column1" class="column" style="width:960px;margin-right:10px;">
<h1>Account Transactions:</h1>
<h3>Pinned Transactions:</h3>
<i>Pinning a transaction is useful if you have a transaction that is important; that you might need in the future!</i>
<p>
<table>
<thead>
<tr><td>ID</td><td>Description</td><td>Credits</td><td>Pixels</td><td>Stars</td><td>Purchase Date</td><td></td></tr>
</thead>
<tbody>
<form method="post">
<?php
$getTrans = dbquery("SELECT * FROM cms_transactions WHERE userid = '".USER_ID."' AND pin = '1' ORDER BY date DESC LIMIT 100");
$oe = 1;
while($transaction = mysql_fetch_assoc($getTrans)){
if ($oe == 2)
{
$oe = 1;
}
else
{
$oe = 2;
}
$oDate = strtotime($transaction['date']);
$sDate = date("<b>l, j - F, o</b> g:ha",$oDate);
$transs = $transaction['id'];
if(isset($_POST["un$transs"])){
dbquery("UPDATE cms_transactions SET pin = '0' WHERE id = '".$transs."' AND userid = '".USER_ID."' LIMIT 1");
header("Location: ".WWW."/identity/transactions");
}
echo'
<tr style=" background-color: ' . (($oe == 2) ? '#e2e2e2' : '#fff') . ';">
<td>'.$transaction['id'].'</td>
<td>'.$transaction['descr'].'</td>
<td>'.$transaction['credits'].' deducted</td>
<td>'.$transaction['amount'].' deducted</td>
<td>'.$transaction['vip_points'].' deducted</td>
<td>'.$sDate.'</td>
<td><input type="submit" value="- Pin" name="un'.$transaction['id'].'" /></td>
</tr>
';
}
if(mysql_num_rows($getTrans) == 0){
echo '<div class="error" id="black">You have no Pinned Transactions</div>';
}
?>
</form>
</tbody>
</table>
</p>
<h3>Recent Transactions</h3>
<p>
<table>
<thead>
<tr><td>ID</td><td>Description</td><td>Credits</td><td>Pixels</td><td>Stars</td><td>Purchase Date</td><td></td></tr>
</thead>
<tbody>
<form method="post">
<?php
$getTrans = dbquery("SELECT * FROM cms_transactions WHERE userid = '".USER_ID."' AND pin = '0' ORDER BY date DESC LIMIT 50");
$oe = 1;
while($transaction = mysql_fetch_assoc($getTrans)){
if ($oe == 2)
{
$oe = 1;
}
else
{
$oe = 2;
}
$oDate = strtotime($transaction['date']);
$sDate = date("<b>l, j - F, o</b> g:ha",$oDate);
$trans = $transaction['id'];
if(isset($_POST["$trans"])){
dbquery("UPDATE cms_transactions SET pin = '1' WHERE id = '".$trans."' AND userid = '".USER_ID."' LIMIT 1");
header("Location: ".WWW."/identity/transactions");
}
echo'
<tr style=" background-color: ' . (($oe == 2) ? '#e2e2e2' : '#fff') . ';">
<td>'.$transaction['id'].'</td>
<td>'.$transaction['descr'].'</td>
<td>'.$transaction['credits'].' deducted</td>
<td>'.$transaction['amount'].' deducted</td>
<td>'.$transaction['vip_points'].' deducted</td>
<td>'.$sDate.'</td>
<td><input type="submit" value="+ Pin" name="'.$transaction['id'].'" /></td>
</tr>
';
}
if(mysql_num_rows($getTrans) == 0){
echo '<div class="error" id="black">You have no recent Transactions</div>';
}
?>
</form>
</tbody>
</table>
</p>
</div>
<style>
td {
padding:10px;
}
tbody td {
text-shadow:0 1px 0 #fff;
}
thead td {
font-weight:bold;
text-align:center;
}
</style>
有一堆关于这个问题已经:[这里](http://stackoverflow.com/a/8028987/184124)即将与解决方案 – HorusKol
通常使用的方法问题的一个很好的,详细的解答首先是做页面处理;在完成之后,包含**内容文件**,并简单地在内容中使用处理结果。 –