duanju7199 2017-06-11 01: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 01: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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部