所以我是PHP的新手,我在修剪功能方面遇到了一些困難。使用MySQL獲取數據後的PHP修剪
基本上我需要
- 修剪@ example.com所有AGENT_EMAIL值。
- 修剪traffic_source下降到30個字符,即http://www.example.com/ex/test ...
這裏是我的源代碼。
<?php
include "../include/setup.inc.php";
$query="SELECT offer_id,title,email,phone,site,zip,price,return_customer,request_date,traffic_source,agent_email,released FROM jos_quote
where request_date >= '2011-10-04' order by request_date";
$result = mysql_query($query);
if (!$result) {echo "<p><b>".$query ."</b></p>";echo 'MySQL Error: ' . mysql_error(); return;}
$num_rows = mysql_num_rows($result);
echo '<br><table border="1" align="center" width="700px">
<tr bgcolor="#FF8000"><td colspan="11" align="center">Total: '.$num_rows.'quotes - Date Range: '.$_POST['date1'].' -- '.$_POST['date2'].' </td></tr>
<tr><th>Title</th><th>Email</th><th>Site</th><th>Zip</th><th>Price</th>
<th>Return Customer</th><th>Request Date</th><th>Agent</th><th>Released</th><th>Traffic Source</th>';
while ($row = mysql_fetch_assoc($result)) {
echo '<tr>
<td>'.$row['title'].'</td>
<td>'.$row['email'].'</td>
<td>'.$row['site'].'</td>
<td>'.$row['zip'].'</td>
<td>'.$row['price'].'</td>
<td>'.$row['return_customer'].'</td>
<td>'.$row['request_date'].'</td>
<td>'.$row['agent_email'].'</td>
<td>'.$row['released'].'</td>
<td>'.$row['traffic_source'].'</td>
</tr>';
}
echo '</table>';
$query="select agent_email,num_quote,num_receive,set_date from quote_distro where set_date >= '2011-10-04'";
$result = mysql_query($query);
if (!$result) {echo "<p><b>".$query ."</b></p>";echo 'MySQL Error: ' . mysql_error(); return;}
while ($row = mysql_fetch_assoc($result)) {
$quote_info[$row['agent_email']][$row['set_date']] =$row;
}
}
?>