私はそれがどのように機能するかを理解するのに本当に苦労しているので、PHPを使用したJOINに関してあなたが私のために物事を明確にしてくれることを本当に望んでいます.
基本的に、プレミアム メンバー用とこれらのメンバーのファン用の 2 つのテーブルがあります。そこで、メンバー ( $memberid
) がファンである「プレミアム」テーブルから特定の情報を取得したいと考えています。
Premium = id, name, avatar, town, etc, etc
Fans = fan($memberid), fanee(Premium ID)
だから私は現時点でこのコードを持っています:
<?php
$get_connections_sql = "SELECT id, name, avatar, town FROM premium LEFT JOIN fans ON fans.fanee=premium.id WHERE fans.fan=$memberid LIMIT 18";
$get_connections_res = mysqli_query($con, $get_connections_sql);
if(mysqli_affected_rows($con)>0){
while ($connections = mysqli_fetch_assoc($get_connections_res)){
$connectionid = $connections['id'];
$connectionname = $connections['name'];
$connectiontown = $connections['town'];
$connectionavatar = $connections['avatar'];
$connections .= "
<div class=\"connectionHolder\"><img class=\"connection\" src=\"uploads/avatars/pro/$connectionavatar\" /></div>
";
}
}else{
$connections = "
<div class=\"noContent\">There are no connections to be shown</div>
";
}
?>
これはelse条件を返しているので、私のJOIN行に何か問題があるに違いありません - 誰でも私を正しい方向に向けてください。