<?php
/**
*
*@author tanqing
*@date 2015年7月16日
*email [email protected]
*/
/*
* $str = file_get_contents('./a.txt')
* $str = preg_replace('/\s/', '#', $str)
* $arr = explode('#', $str)
* print_r($arr)
* $data['riqi'] = $arr[0]
* $data['qihao'] = $arr[1]
*/
header("Content-type: text/htmlcharset=utf-8")
$link = mysql_connect('127.0.0.1','root','123456')
$database = 'mytest'
$tab_1_sql= 'select * from tab_1'
$tab_1_result = mysql_db_query($database, $tab_1_sql)
while ($tab_1_row = mysql_fetch_assoc($tab_1_result)){
$tab1Result[$tab_1_row['pid']] = $tab_1_row['name']
}
$query = 'select * from tab_2 '
$result = mysql_db_query($database, $query)
$row=mysql_fetch_row($result)
while ($row=mysql_fetch_assoc($result))
{
$rowResult[$row['date']][$row['pid']] = $row['val']
}
?>
<table>
<tr>
<td>日期</td>
<?php foreach ($tab1Result as $pid=>$pname){?>
<td><?php echo $pname?></td>
<?php }?>
</tr>
<?php foreach ($rowResult as $date=>$val){?>
<tr>
<td><?php echo $date?></td>
<?php foreach ($tab1Result as $pid=>$pname){?>
<td><?php if ($val[$pid]) {
echo $val[$pid]
}else{
echo 0
} ?></td>
<?php }?>
</tr>
<?php }?>
</table>
打印结果
php中,.是连接符,改成这样$proname = "SELECT areaname FROM oepre_user_params JOIN oepre_hometown ON oepre_user_params".".`provinceid` = oepre_hometown.`areaid` WHERE userid=123
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)