php - 使用php和mysql的菜单问题

标签 php mysql menubar

我有一个包含两列的表,分别称为 rugby_union 和 matchleague。 我创建了 2 个查询来显示不同的 rugby_union 和 matchleague。当我在菜单上有下拉菜单时,它必须仅显示来自 rugby_union 的 matchleague。 这是我正在使用的代码:

$sql="select distinct(union_league) from teams where league_complete ='No' ";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)){ 
$matchleaguecomp[] = $row; 
}

$sql1="select distinct(rugby_union) AS rugby_union from teams where league_complete ='No' ";
$query1 = mysql_query($sql1);
while($row1 = mysql_fetch_array($query1)){ 
$union_list[] = $row1; 
}

导航栏中的 PHP 代码:

<?php                       
    for($i=0;$i<count ($union_list);$i++){  
?>
<li>
    <a href="#"><?php echo $union_list[$i][0]; ?></a>
    <ul class="dropdown-menu" 
         style="position: absolute; left: 160px; top: 0px; display: none;
                height: <?php if(count($matchleaguecomp)>0) {
                                  echo '260px;'; 
                              } else { 
                                  echo (count($matchleaguecomp)*26).'px'; 
                              } ?>  
                overflow: auto;">
        <?php
            for($i=0;$i<count($matchleaguecomp);$i++){                      
                //$fixture_name=$url->encode("name=".$matchleaguecomp[$i][0]);
            $fixture_name="name=".$matchleaguecomp[$i][0];
        ?>
        <li>
            <a href="<?php echo $include_path.'new_logs.php?'.$fixture_name; ?>">
                <?php echo $matchleaguecomp[$i][0]; ?>
            </a>
        </li>
        <?php  } ?>
    </ul>
</li>
<?php  } ?> 

提前感谢,我不明白为什么它不显示联盟的工会列表

最佳答案

首先,请注意 @tadman 所说的有关 mysql_query 已过时的内容... 这是您的固定代码:

$sql="select distinct(union_league) as `union_league` from teams where league_complete ='No' ";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)){ 
$matchleaguecomp[] = $row['union_league']; // you need to get the returned value from the array
}

$sql1="select distinct(rugby_union) AS rugby_union from teams where league_complete ='No' ";
$query1 = mysql_query($sql1);
while($row1 = mysql_fetch_array($query1)){ 
$union_list[] = $row1['rugby_union']; // you need to get the returned value from the array
}

关于php - 使用php和mysql的菜单问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24273514/

相关文章:

php - SQLSTATE[42S22] : Column not found: 1054 Unknown column - Laravel

php - 将 CSS 规则减少到最小公分母

php - EXTJS & PHP 上传文件

php - 如何在 SSL 页面上使用不安全的 Web 脚本

c# - 当 ID 字段 (PK) 自动递增时(带有 EF 的 MySQL),使用与之前相同的 Id 恢复已删除的记录

C# Mysql 创建表名带空格

mysql - sql查询的国际化

html - Primefaces 菜单栏右对齐子菜单

html - 水平双层 CSS 菜单(包含 jsfiddle)

firefox - linux 操作系统中缺少 selenium ide 菜单栏