21,886
社区成员
发帖
与我相关
我的任务
分享
while($row = mysql_fetch_array($result))
$result1 = mysql_query("select * from jtrb1 where name='上衣' and price < 300");
$row1 = mysql_fetch_array($result1);
$result2 = mysql_query("select * from jtrb2 where name='上衣' and price < 300");
$row2 = mysql_fetch_array($result1);
$result3 = mysql_query("select * from jtrb3 where name='上衣' and price < 300");
$row3 = mysql_fetch_array($result3);
组合
select * from jtrb1,jtrb2,jtrb3
where jtrb1.name='上衣' and jtrb1.price < 300
and jtrb2.name='上衣' and jtrb2.price < 300
and jtrb3.name='上衣' and jtrb3.price < 300
mysql_query("set character set 'utf8'");//读库
mysql_query("set names 'utf8'");//写库
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$query="SELECT * FROM jtrb1,jtrb2,jtrb3 WHERE jtrb1.name='上衣' and jtrb2.name='上衣' and jtrb3.name='上衣'";
$result= mysql_query($query,$con)or die(mysql_error());
$row= mysql_fetch_array($result);
while($row)
{
echo $row['jtrb1.Name']."<br>";
//下面省略
}
mysql_close();
?>
我这样子写输出空白。请大神指点。[/quote]
把数组打印出来。。用foreach试一试。[/quote]
foreach 也是空白。SQL在phpmyadmin里可以输出内容,求解!select * from (
select * from jtrb1 where jtrb1.name='上衣' and jtrb1.price < 300
union all
select * from jtrb2 where jtrb2.name='上衣' and jtrb2.price < 300
union all
select * from jtrb3 where jtrb3.name='上衣' and jtrb3.price < 300
) as t
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$query="SELECT * FROM jtrb1,jtrb2,jtrb3 WHERE jtrb1.name='上衣' and jtrb2.name='上衣' and jtrb3.name='上衣'";
$result= mysql_query($query,$con)or die(mysql_error());
$row= mysql_fetch_array($result);
while($row)
{
echo $row['jtrb1.Name']."<br>";
//下面省略
}
mysql_close();
?>
我这样子写输出空白。请大神指点。[/quote]
把数组打印出来。。用foreach试一试。<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$query="SELECT * FROM jtrb1,jtrb2,jtrb3 WHERE jtrb1.name='上衣' and jtrb2.name='上衣' and jtrb3.name='上衣'";
$result= mysql_query($query,$con)or die(mysql_error());
$row= mysql_fetch_array($result);
while($row)
{
echo $row['jtrb1.Name']."<br>";
//下面省略
}
mysql_close();
?>
我这样子写输出空白。请大神指点。