0
이것은 내 코드이며 2 테이블의 데이터가 필요합니다. 첫 번째 : ps_customer(id_customer,firstname,lastname,email)
및 두 번째 : ps_adress(phone_mobile)
.2 mysql 테이블에서 데이터를 얻는 방법
<?php
$conn=mysqli_connect("localhost","login","pass","dbNAME");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$gender = 6;
$sql =
"SELECT
ps_customer.id_customer, ps_customer.firstname, ps_customer.lastname, ps_customer.email, ps_adress.phone_mobile
FROM
ps_customer, ps_adress
ps_customer.id_gender = '$gender' ";
$rs=mysql_query($sql,$conn) or die(mysql_error());
echo '<table width="100%" border="0" cellspacing="5" cellpadding="5">';
while($result=mysql_fetch_array($rs))
{
echo '<tr>
<td>'.$result["id_customer"].'</td>
<td>'.$result["firstname"].'</td>
<td>'.$result["lastname"].'</td>
<td>'.$result["email"].'</td>
<td>'.$result["phone_mobile"].'</td>
</tr>';
}
echo '</table>';
?>
'ps_customer.id_gender = '$ gender' ";' –
두 테이블이 어떻게 관련되어 있는지 지정하지 않았습니다. (INNER JOIN 또는 OUTTER JOIN) 두 테이블 사이에 일치하는 위치입니다 .. http://www.w3schools.com/sql/sql_join_inner.asp –
실제로 그는','를 사용하여 지정했는데 교차 결합이 발생하지만 원하는 결과는 아닙니다 – xQbert