预先感谢您检查我的帖子。我会尝试直接了解细节
背景:我正在尝试从SQL中提取报价,线索和订单数据,并使用PHP的Heredoc在多个表中显示这些数据。每个查询都有两个表,分别为“代表”和“按地区”。
我要执行的操作:我想并排显示带有标识标题的表,并在标题下并排显示一行,然后在该表的下面一行中显示下一组表。
问题:当我将标题放置在我认为应该放在代码中的位置(在第二组表table1中的heredoc中)时,它将所有格式全部抛出窗口并以一种奇怪的方式显示。(参见屏幕截图)
我对PHP还是很陌生,几乎没有CSS或HTML的经验,您将能够从下面的代码,帮助和说明中了解到为什么它不能以这种方式工作,这将不胜感激。我已经从第一部分代码中复制了第二组表,以说明我遇到的问题,它最终会改变。我敢肯定这是一个愚蠢的错误,所以请对我的菜鸟灵魂好一点。贝娄是代码和它的外观的屏幕快照。 ScreenShot
<style rel="stylesheet" type="text/css">
caption{
font-size:30px;
font-weight: bold;
text-align:center;
}
.table1 {
width=80%;
float:left;
margin-left:120px;
}
.table2 {
width=45%;
float:right;
margin-right:700px;
}
</style>
<?php
/**
* Finds the amount of quotes generated by a specific territory
*
*
* @author Trevor-Prosales 11/05/2018
*
* *
*/
//Search by date bar
print "<h3>All Quotes Report</h3>";
//sets date
if (!strlen($end_date)){
$end_date = date("Y-m-d");
}
if ( strtotime($end_date)==-1||strtotime($end_date)===false ){
$end_date = date("Y-m-d");
}
$end_date = make_display_date($end_date);
//adds the text field to search
$form = <<<__THIS
<form method=post action="" name="dateForm">
Most recent date to show: <input type="text" name="end_date" value="$end_date">
<input type="hidden" name="dateForm_submitted" value="1">
<input type="hidden" name="orderby" value="quote_num">
<input type="hidden" name="sortorder" value="desc">
<input type="submit" value="View Quotes">
</form>
<br />
__THIS;
print $form;
//first set of tables
if ($dateForm_submitted || ($QuoteForm_submitted && $deleteOrders==0))
{
//day,week,month,year,twoyear
$db_end_date = date("Y-m-d",strtotime($end_date));
$db_end_date1 = date("Y-m-d",strtotime($end_date) - 86400);
$db_end_date2 = date("Y-m-d",strtotime($end_date) - 604800);
$db_end_date3 = date("Y-m-d",strtotime($end_date) - 60*60*24*30);
$db_end_date4 = date("Y-m-d",strtotime($end_date) - 60*60*24*30*12);
$db_end_date5 = date("Y-m-d",strtotime($end_date) - 60*60*24*30*24);
//First Table
if (!strlen($orderby)) $orderby="rep2";
if (!strlen($sortorder)) $sortorder="desc";
$sql = "Select rep2,
SUM(CASE When quote_date BETWEEN '" .$db_end_date1 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Daily,
SUM(CASE When quote_date BETWEEN '" .$db_end_date2 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Weekly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date3 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Monthly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date4 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Yearly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date5 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) 2Yearly
FROM so_orders
WHERE rep2 = '401' OR rep2= '399' OR rep2= '142' OR rep2= '332'
GROUP BY rep2 ORDER BY $orderby $sortorder";
$res=db_query($sql);
$num_rows = db_num_rows($res);
if (! $num_rows )
kill(getErrorMessage(161));
print <<<__THAT
<h1 >Number of Quotes Entered:<hr></h1>
<form method=post action="" name="QuoteForm">
<input type="hidden" name="orderby" value="$orderby">
<input type="hidden" name="sortorder" value="$sortorder">
<input type="hidden" name="QuoteForm_submitted" value="1">
<table class="table1" frame="box" cellspacing=0 cellpadding=0>
<caption>By Territory</caption>
<tr class=rowcolor>
<td class=cellborderbt>Sales Rep</td>
<td class=cellborderbt>Daily</td>
<td class=cellborderbt nowrap>Weekly</td>
<td class=cellborderbt nowrap>Monthly</td>
<td class=cellborderbt>Yearly</td>
<td class=cellborderbt>2 Year</td>
</tr>
__THAT;
while($data=db_fetch_array($res) )
{
$rowClass = ($rowClass=="roweven")?"rowodd":"roweven";
$quote_date = make_display_date($data['quote_date']);
print <<<__THIS
<tr class="{$rowClass}">
<td>{$data['rep2']}</td>
<td>{$data['Daily']}</td>
<td>{$data['Weekly']}</td>
<td>{$data['Monthly']}</td>
<td>{$data['Yearly']}</td>
<td>{$data['2Yearly']}</td>
</tr>
__THIS;
}
print <<< __THIS
</table>
__THIS;
//second table
if (!strlen($orderby)) $orderby="rep1";
if (!strlen($sortorder)) $sortorder="desc";
$sql2 = "Select rep1,
SUM(CASE When quote_date BETWEEN '" .$db_end_date1 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Daily,
SUM(CASE When quote_date BETWEEN '" .$db_end_date2 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Weekly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date3 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Monthly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date4 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Yearly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date5 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) 2Yearly
FROM so_orders
WHERE rep1 = '231' OR rep1= '339' OR rep1= '401' OR rep1= '399' OR rep1= '142' OR rep1= '332' OR rep1 ='414'
GROUP BY rep1 ORDER BY $orderby $sortorder";
$res2=db_query($sql2);
$num_rows2 = db_num_rows($res2);
if (! $num_rows )
kill(getErrorMessage(161));
print <<<__THIS
<form method=post action="" name="QuoteForm">
<input type="hidden" name="orderby" value="$orderby">
<input type="hidden" name="sortorder" value="$sortorder">
<input type="hidden" name="QuoteForm_submitted" value="1">
<table class="table2" frame="box" cellspacing=0 cellpadding=0>
<caption>By Rep</caption>
<tr class=rowcolor>
<td class=cellborderbt>Sales Rep</td>
<td class=cellborderbt>Daily</td>
<td class=cellborderbt>Weekly</td>
<td class=cellborderbt>Monthly</td>
<td class=cellborderbt>Yearly</td>
<td class=cellborderbt>2 Year</td>
</tr>
__THIS;
while($data=db_fetch_array($res2) )
{
$rowClass = ($rowClass=="roweven")?"rowodd":"roweven";
$quote_date = make_display_date($data['quote_date']);
print <<<__THIS
<tr class="{$rowClass}">
<td>{$data['rep1']}</td>
<td>{$data['Daily']}</td>
<td>{$data['Weekly']}</td>
<td>{$data['Monthly']}</td>
<td>{$data['Yearly']}</td>
<td>{$data['2Yearly']}</td>
</tr>
__THIS;
}
print <<< __THIS
</table>
__THIS;
} //end of if statement
/**
//second set of tables
//*
//*
*/
if ($dateForm_submitted || ($QuoteForm_submitted && $deleteOrders==0))
{
$db_end_date = date("Y-m-d",strtotime($end_date));
$db_end_date1 = date("Y-m-d",strtotime($end_date) - 86400);
$db_end_date2 = date("Y-m-d",strtotime($end_date) - 604800);
$db_end_date3 = date("Y-m-d",strtotime($end_date) - 60*60*24*30);
$db_end_date4 = date("Y-m-d",strtotime($end_date) - 60*60*24*30*12);
$db_end_date5 = date("Y-m-d",strtotime($end_date) - 60*60*24*30*24);
//First Table
if (!strlen($orderby)) $orderby="rep2";
if (!strlen($sortorder)) $sortorder="desc";
$sql = "Select rep2,
SUM(CASE When quote_date BETWEEN '" .$db_end_date1 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Daily,
SUM(CASE When quote_date BETWEEN '" .$db_end_date2 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Weekly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date3 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Monthly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date4 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Yearly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date5 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) 2Yearly
FROM so_orders
WHERE rep2 = '401' OR rep2= '399' OR rep2= '142' OR rep2= '332'
GROUP BY rep2 ORDER BY $orderby $sortorder";
$res=db_query($sql);
$num_rows = db_num_rows($res);
if (! $num_rows )
kill(getErrorMessage(161));
print <<<__THAT
<h1 >Number of Leads Entered:<hr></h1>
<form method=post action="" name="QuoteForm">
<input type="hidden" name="orderby" value="$orderby">
<input type="hidden" name="sortorder" value="$sortorder">
<input type="hidden" name="QuoteForm_submitted" value="1">
<table class="table2" frame="box" cellspacing=0 cellpadding=0>
<caption>By Territory2</caption>
<tr class=rowcolor>
<td class=cellborderbt>Sales Rep</td>
<td class=cellborderbt>Daily</td>
<td class=cellborderbt nowrap>Weekly</td>
<td class=cellborderbt nowrap>Monthly</td>
<td class=cellborderbt>Yearly</td>
<td class=cellborderbt>2 Year</td>
</tr>
__THAT;
while($data=db_fetch_array($res) )
{
$rowClass = ($rowClass=="roweven")?"rowodd":"roweven";
$quote_date = make_display_date($data['quote_date']);
print <<<__THIS
<tr class="{$rowClass}">
<td>{$data['rep2']}</td>
<td>{$data['Daily']}</td>
<td>{$data['Weekly']}</td>
<td>{$data['Monthly']}</td>
<td>{$data['Yearly']}</td>
<td>{$data['2Yearly']}</td>
</tr>
__THIS;
}
print <<< __THIS
</table>
__THIS;
//second table
if (!strlen($orderby)) $orderby="rep1";
if (!strlen($sortorder)) $sortorder="desc";
$sql2 = "Select rep1,
SUM(CASE When quote_date BETWEEN '" .$db_end_date1 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Daily,
SUM(CASE When quote_date BETWEEN '" .$db_end_date2 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Weekly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date3 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Monthly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date4 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) Yearly,
SUM(CASE When quote_date BETWEEN '" .$db_end_date5 . "' And '".$db_end_date."' THEN 1 ELSE 0 END) 2Yearly
FROM so_orders
WHERE rep1 = '231' OR rep1= '339' OR rep1= '401' OR rep1= '399' OR rep1= '142' OR rep1= '332' OR rep1 ='414'
GROUP BY rep1 ORDER BY $orderby $sortorder";
$res2=db_query($sql2);
$num_rows2 = db_num_rows($res2);
if (! $num_rows )
kill(getErrorMessage(161));
print <<<__THIS
<form method=post action="" name="QuoteForm">
<input type="hidden" name="orderby" value="$orderby">
<input type="hidden" name="sortorder" value="$sortorder">
<input type="hidden" name="QuoteForm_submitted" value="1">
<table class="table1" frame="box" cellspacing=0 cellpadding=0>
<caption>By Rep2</caption>
<tr class=rowcolor>
<td class=cellborderbt>Sales Rep</td>
<td class=cellborderbt>Daily</td>
<td class=cellborderbt>Weekly</td>
<td class=cellborderbt>Monthly</td>
<td class=cellborderbt>Yearly</td>
<td class=cellborderbt>2 Year</td>
</tr>
__THIS;
while($data=db_fetch_array($res2) )
{
$rowClass = ($rowClass=="roweven")?"rowodd":"roweven";
$quote_date = make_display_date($data['quote_date']);
print <<<__THIS
<tr class="{$rowClass}">
<td>{$data['rep1']}</td>
<td>{$data['Daily']}</td>
<td>{$data['Weekly']}</td>
<td>{$data['Monthly']}</td>
<td>{$data['Yearly']}</td>
<td>{$data['2Yearly']}</td>
</tr>
__THIS;
}
print <<< __THIS
</table>
__THIS;
}
?>