Home > Backend Development > PHP Tutorial > 有关UNION与WHERE的有关问题

有关UNION与WHERE的有关问题

WBOY
Release: 2016-06-13 13:16:06
Original
927 people have browsed it

有关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上传至下一页

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template