识别单词

时间:2017-06-11 09:02:20

标签: php

我为我在字典网站中使用的翻译table编写了此代码。



<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>
&#13;
&#13;
&#13;

不幸的是,下面的代码并未将我重定向到我从转换表中选择的特定字词。

&#13;
&#13;
<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>
&#13;
&#13;
&#13;

它向我显示this url,但您可以看到语言未定义。我想要做的是告诉,如果这个词是例如&#34; test&#34;它是一个英文翻译,用于将我重定向到该特定语言的单词,因为它在数据库中设置。有谁知道如何使这项工作?

1 个答案:

答案 0 :(得分:1)

$word_language未定义。请改用$v['word_language']

<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>