ajax_get_my_words.php 1.71 KB
<?php
// 发送短信验证码
require_once ("../user_include.inc");

$ta = new TemplateAction();
if(!$ta->isLogin()) {
	print json_encode(array("count"=>0, "html"=>""));
	exit;
}

//检索用户收录的单词
$sql = "select w.* from word_dat w, user_favorite_dat u where w.delete_flg=false and u.delete_flg=false and u.data_type='word' and u.user_id='{$ta->user->id}' and u.data_id=w.id order by u.id desc";
error_log("Koala...ajax_get_my_words.php...sql=" . $sql, 0);
$db = &KoalaDBManager::getInstance();
$word_data_list = $db->executeQuery($sql);

$word_count = count($word_data_list);
$index = 0;
ob_start();
foreach($word_data_list as $tmp) {
	$index++;
	$word_dat = new WordDat($tmp);
?>
		<div class="word_item">
			<div class="word_row">
				<div class="index"><?=$index?>/<?=$word_count?></div>
				<div class="title"><?=$word_dat->word?></div>
				<div class="audio" onClick="playMp3('http://<?=SCHOOL_DOMAIN?>/mp3.php?file_name=<?=$word_dat->mp3?>');"><img src="images/audio.png"></div>
			</div>
			<div class="hira_kana_row">假名拼写:<?=$word_dat->hira_kana?></div>
			<?
				if(!empty($word_dat->chinese)) {
			?>
			<div class="chinese_row">释义:<?=$word_dat->chinese?></div>
			<?
				}
			?>
			<?
				if(!empty($word_dat->sample)) {
			?>
			<div class="sample_row">释义:<?=$word_dat->chinese?></div>
			<?
				}
			?>
			<?
				if(!empty($word_dat->comment)) {
			?>
			<div class="comment_row">用法:<?=$word_dat->comment?></div>
			<?
				}
			?>
			<div class="love_row">
				<div class="love"><img src="images/love2.png" onClick="deleteFavorite('word', '<?=$word_dat->id?>');"></div>
			</div>
		</div>
<?
}
$html = ob_get_contents();
ob_end_clean();
print json_encode(array("word_count"=>$word_count, "html"=>$html));
?>