duanju7199 2017-06-11 09:02
浏览 17
已采纳

识别单个的多个href重定向

I wrote this code for a translation table which I use inside my dictionary website.

<div class="row">
                <?php
                    $stmt_word1 = $auth_user->runQuery("SELECT * FROM word_language_meanings WHERE word_id = '".$word_id."'");
                    $stmt_word1->execute();
                    $wordLangRows=$stmt_word1->fetchAll(PDO::FETCH_ASSOC);
                    
                    $counter = 1;
                    foreach($wordLangRows as $k => $v)
                    {
                        if($v['word_language'] != $language)
                        {
                ?>
                <div class="col-sm-4 black_color" id="col-sm-4-translations">
                    <h5><strong><?php echo $v['word_language']; ?></strong></h5>
                    <span class="<?php if($v['word_language'] == 'Старобългарски') { echo 'bulgarian_font'; } ?>"><a style="color: gray;" href="dictionary.php?meaning=<?php echo $v['word_meaning']; ?>&language=<?php echo $word_language; ?>"><?php echo $v['word_meaning']; ?></a></span>
                </div>
                <?php
                        }
                    }
                ?>
            </div>

Unfortunately the code below does not redirect me to the particular word I'd choose from the translation table.

<span class="<?php if($v['word_language'] == 'Старобългарски') { echo 'bulgarian_font'; } ?>"><a style="color: gray;" href="dictionary.php?meaning=<?php echo $v['word_meaning']; ?>&language=<?php echo $word_language; ?>"><?php echo $v['word_meaning']; ?></a></span>

It shows me this url but as u can see the language is not defined. What I am trying to do is to tell, if the word is for example "test" and its an english translation, to redirect me to that word of that particular language, as it's set in the database. Has anyone any idea how to make this work?

</div>
  • 写回答

1条回答 默认 最新

  • doubihuai8468 2017-06-11 09:06
    关注

    $word_language is not define. Use $v['word_language'] instead

    <span class="<?php if($v['word_language'] == 'Старобългарски') { echo 'bulgarian_font'; } ?>"><a style="color: gray;" href="dictionary.php?meaning=<?php echo $v['word_meaning']; ?>&language=<?php echo $v['word_language'] ?>"><?php echo $v['word_meaning']; ?></a></span>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题