查询复制结果

时间:2018-04-25 20:01:57

标签: php mysql

我正在尝试从拖车桌上的列上选择数据,但我得到重复的数据

表1:ID P_name Image_url cat_number价格对象T_email loc_a loc_o

表2:n_p名称电子邮件密码电话Location_lat Location_long
我不会只在T_email = trader.Email

时选择

它得到了表2中的所有trader.Email

<?php


$host='127.0.0.1';


$username='root';
$pwd='123';


$db="catcher_database";



$con=mysqli_connect($host,$username,$pwd,$db) or die('Unable to connect');


$email = $_POST['email'];
$interrest_a=$_POST["interrest_a"];
$interrest_b=$_POST["interrest_b"];
$interrest_c=$_POST["interrest_c"];
$interrest_d=$_POST["interrest_d"];
//$interrest_e=$_POST["interrest_e"];
$interrest_e="Restaurants";
if(!empty($email)){

if(mysqli_connect_error($con))
{
    echo "Failed to Connect to Database ".mysqli_connect_error();
}




$sql="SELECT * FROM product,trader WHERE trader.Email=product.T_email and product.T_email = '$email'";




$result=mysqli_query($con,$sql);


if($result)
{
    while($row=mysqli_fetch_array($result))
    {
        $data[]=$row;
    }




    print(json_encode($data)); }
}
else
{

if(mysqli_connect_error($con))
{
    echo "Failed to Connect to Database ".mysqli_connect_error();
}




$sql="SELECT * FROM product,trader WHERE product.T_email = trader.Email  and product.cat_number='$interrest_a'or product.cat_number='$interrest_b'or product.cat_number='$interrest_c'or product.cat_number='$interrest_d'or product.cat_number='$interrest_e'";




$result=mysqli_query($con,$sql);


if($result)
{
    while($row=mysqli_fetch_array($result))
    {
        $data[]=$row;
    }




    print(json_encode($data)); }
}





mysqli_close($con);


?>

0 个答案:

没有答案