我在数据库中创建了一个名为(wp\\u answers)的表来获取波斯语句子。所以我用get_charset_collate
. 现在,数据库中的字符串已正确保存。但当我想提取这些字符串时,它们并没有正确显示。例如:如何更正此问题?这是我的代码的一部分,用于创建answers表并从此表中提取字符串。谢谢
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$answers_table = $wpdb->prefix. \'answers\';
if( $wpdb->get_var( "SHOW TABLES LIKE \'{$answers_table}\'" ) != $answers_table ){
$query =
"CREATE TABLE {$answers_table} (
poll_id BIGINT(20),
ans_id BIGINT(20),
ans_title VARCHAR(32),
votes BIGINT(20),
PRIMARY KEY (poll_id,ans_id)
) $charset_collate;";
require_once( ABSPATH. \'wp-admin/includes/upgrade.php\' );
dbDelta( $query );
}
-提取:
<?php
$result = $wpdb->get_results("SELECT ans_title,votes
FROM wp_answers
WHERE poll_id=$post_id AND ans_id=$answer_id");
?>
<h2><?php echo $result[0]->ans_title; ?><h2> //This would show سلام instead of سلام