我有一个搜索表单,您可以根据需要选择您的选择,选择后单击“提交”按钮,您将被重定向到搜索列表页面,您可以在其中检查用户的列表,一切正常,但问题是我正在获取每个列表记录两次。
从下面的代码:
<?php
include_once('dbconn.php');
$looking_for = $_POST['looking_for'];
$religion = $_POST['religion'];
$mother_tongue = $_POST['mother_tongue'];
$query = "SELECT * FROM user INNER JOIN profile_description where gender like '".$looking_for."' AND religion like '%".$religion."%' AND mother_tongue like '%".$mother_tongue."%'";
$result = mysql_query($query);
while ($result_row = mysql_fetch_row(($result))){
$profile_created_by = $result_row[1];
$religion = $result_row[6];
$mother_tongue = $result_row[7];
$city = $result_row[15];
$community = $result_row[16];
$height = $result_row[17];
$education_level = $result_row[23];
$education_field = $result_row[24];
$working_with = $result_row[26];
$describe_yourself = $result_row[28];
?>
<div class="search_list wrap">
<p>Profile created by <?php echo ucwords($profile_created_by); ?></p>
<div class="search_list_image">
<img src="img/groom-1.jpg">
</div>
<div class="profile_basic">
<label class="label">Age / Height</label><div class="info">25, <?php echo $height; ?></div>
<div class="clearfix"></div><div class="spacer_4"></div>
<label class="label">Religion</label><div class="info"><?php echo ucwords($religion); ?></div>
<div class="clearfix"></div><div class="spacer_4"></div>
<label class="label">Mother Tongue</label><div class="info"><?php echo ucwords($mother_tongue); ?></div>
<div class="clearfix"></div><div class="spacer_4"></div>
<label class="label">Community</label><div class="info"><?php echo ucwords($community); ?></div>
<div class="clearfix"></div><div class="spacer_4"></div>
<label class="label">Location</label><div class="info"><?php echo ucwords($city); ?></div>
<div class="clearfix"></div><div class="spacer_4"></div>
<label class="label">Education</label><div class="info"><?php echo ucwords($education_level); ?> - <?php echo ucwords($education_field); ?></div>
<div class="clearfix"></div><div class="spacer_4"></div>
<label class="label">Profession</label><div class="info"><?php echo ucwords($working_with); ?></div>
<div class="clearfix"></div>
</div>
<div class="search_list_link">
<a href="#">View full profile</a>
</div>
<div class="search_list_content">
<p><?php echo $describe_yourself; ?></p>
</div>
</div>
<?php } ?>
谁能告诉我我在做什么错?
最佳答案
您应该将要联接两个表的联接方式添加到“联接依据”列。否则,当您为一个用户拥有多个profile_description时,将复制用户表中的每一列