我有一个带有“快速链接”的页面,它显示来自成员表的国家/地区的链接,如果用户点击“阿肯色州”,则与该状态相关联的成员信息将显示在州链接下方。状态链接自动从我们的数据库中提取,我想排除状态链接,目前没有任何条目。我相信我需要编辑这一行,但不知道正确的语法。
$sql1 = mysql_query("select state_id,state_name from ".TABLE_STATE);
感谢您花时间看看这个!对此,我真的非常感激! 这是指向页面的链接(http://homesforhorses.dreamhosters.com/members/),如果需要,下面是其余代码:
<?php
update_option('image_default_link_type','none');
include("/home/cingen/config_admin.php");
function listMembers() {
$sql1 =mysql_query("select state_id,state_name from ".TABLE_STATE);
ob_start(); //send all future echo statements to the buffer instead of output
while($row1=mysql_fetch_assoc($sql1)) { ?>
<a href="#'STATE'" onclick="getDetails(<?php echo $row1["state_id"];?>)"> <?php echo $row1["state_name"]; ?> </a>
<?php } ?>
<br/><br/><div id="resultDiv"></div>
<?php
$result = ob_get_clean(); //capture the buffer into $result
return $result; //return it, instead of echoing
}
add_shortcode('memberlist', 'listMembers');
//Shortcode to list Rescue Standards members
function listRescueStandards() {
$display_members = '';
$sql = mysql_query("SELECT vc.*, s.*, m.*
FROM ".TABLE_COMPLIANCE." vc, ".TABLE_STATE." s, ".TABLE_MEMBERS." m
WHERE vc.member_id = m.cid
AND m.status = '1'
AND m.state = s.state_abbr
ORDER BY m.state, m.organization ASC");
while ($row = mysql_fetch_array($sql)) {
$organization = stripslashes($row['organization']);
if ($row['website']) {
$link = "<a href='http://".$row['website']."' target='_blank'>";
$endlink = "</a>";
} else {
$link = "";
$endlink = "";
}
if($x != $row['state_name']){
$display_members .= "<br /><strong>".strtoupper($row['state_name'])."</strong><br />";
$x = $row['state_name'];
}
$display_members .= $link.$organization.$endlink."<br />
".stripslashes($row['address'])." ".stripslashes($row['address2'])."<br />
".stripslashes($row['city']).", ".stripslashes($row['state'])." ".$row['zip']."<br />";
if ($row['contact_name']) $display_members .= "Contact: ".stripslashes($row['contact_name']);
if ($row['contact_title']) $display_members .= ", ".stripslashes($row['contact_title']);
if ($row['phone']) $display_members .= "<br />Tel: ".stripslashes($row['phone']);
if ($row['fax']) $display_members .= "<br />Fax: ".stripslashes($row['fax']);
if ($row['email']) $display_members .= "<br />".$row['email'];
if ($row['website']) $display_members .= "<br /><a href='http://".$row['website']."' target='_blank'>".$row['website']."</a>";
if ($row['year_est']) $display_members .= "<br />Founded in ".$row['year_est'].".";
if ($row['org501c3'] == "1") $display_members .= "<br />This organization IS registered with the IRS as a 501(c)3.";
if ($row['org501c3'] != "1") $display_members .= "<br />This organization is NOT registered with the IRS as a 501(c)3.";
$display_members .= "<br /><br />";
}
//return "<div class='memberlist'>" . $display_members[$i + ($j * $rows)] . "</div>";
return "<div class='memberlist'>" . $display_members . "</div>";
}
add_shortcode('standardslist', 'listRescueStandards');
?>
答案 0 :(得分:1)
如果不查看您的表格信息,确实很难回答,但也许您想要这样的事情:
$sql1 = mysql_query("select state_id,state_name from ".TABLE_STATE." WHERE website != '');
而不是
$sql1 = mysql_query("select state_id,state_name from ".TABLE_STATE);
如果这不起作用,请提供有关表格结构的更多信息。
编辑:仔细查看代码后,您正在寻找的查询可能如下
$sql1 = mysql_query("select s.state_id,s.state_name from ".TABLE_STATE." s, ".TABLE_MEMBERS." m WHERE m.state = s.state_abbr and m.website !='');