日期:2014-05-17  浏览次数:20440 次

有关UNION与WHERE的问题
$id=$_GET['id']; //另一页面超链接传来的值
$id = "where WebMailUserN=".$id;
//--遍历数组中的所有表中的数据,并显示字段内容
$table = array("content_201202","content_201203","content_201204");
$select = array();
foreach($table as $v) {
$select[]= "(select * from $v $id)";
}
  echo $sqll = join('UNION ',$select);
  $sqll = mysql_query($sqll);
  $num = mysql_num_rows($sqll);//记录总条数,为了分页

$sqln = join(' UNION ',$select)." limit $page $pagesize";
$sqln = mysql_query($sqln);
while($row = mysql_fetch_array($sqln)){.......}

(select * from content_201208 where WebMailUserN=$id)UNION (select * from content_201209 where WebMailUserN=$id)UNION (select * from content_201210 where WebMailUserN=$id)
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in F:\www_local\G04\list_content.php on line 49

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in F:\www_local\G04\list_content.php on line 53


上面代码不知道那有错,不显示数据

------解决方案--------------------
你需要将id连在url上传至下一页