我在查询BuddyPress表的WordPress安装的外部文件上有以下查询。我没有收到任何错误但结果显示?
$the_pro = "". implode(", ", $user) ."";
$query ="SELECT
(SELECT value FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '2') as 'prof',
(SELECT value FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '3') as 'address',
(SELECT value FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '4') AS 'city',
(SELECT value FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '5') AS 'state',
(SELECT value FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '6') AS 'zip',
(SELECT value FROM wp_bp_xprofile_data WHERE 'user_id' IN (" . $the_pro . ") AND field_id = '7') AS 'link'
";
$results = mysql_query($query);
while($row = mysql_fetch_array($results)) {
?>
<div style="padding-bottom:4px; border-bottom:#CCC 1px solid;" >
<div class="prof"><a href="#" onClick="myClick(0);"><?php echo $row['prof']; ?></a></div>
<div class="address"><span style="margin-bottom:3px;"><?php echo $row['address']; ?></div>
<div class="local"><?php echo $row['city']; ?>, <?php echo $row['state']; ?> <?php echo $row['zip']; ?></div>
</div>
<?php
}?>
答案 0 :(得分:0)
请尝试添加: if(!$ result){ 死(&#39;无效的查询:&#39; .mysql_error()); } 所以你知道是否有错误或者它确实返回了空结果。