Welcome Guest, Not a member yet? Register   Sign In
My TableSorter Can't Show DB Chinese Character? Could you help me?
#1

[eluser]Nano HE[/eluser]
Hi,
Good day.

I am test the Tablesorter function (from tablesorter.com)
DB Chinese Character can't show.
HTML Chinese Character could show well.

Could you help me find why?

Thanks a lot!

URL Link:
http://www.ironmanchina.net/duathlonchin...itView.php


Code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Welcome To Duathlon China 2009&lt;/title&gt;
&lt;META http-equiv=Content-Type content="text/html; charset=utf-8"&gt;
    
    &lt;style type="text/css"&gt;@import "assets/css/jq.css";&lt;/style&gt;
    &lt;style type="text/css"&gt;@import "assets/css/style.css";&lt;/style&gt;

    [removed][removed]
    [removed][removed]
    [removed]
    
    $(function() {
        $("table").tablesorter()
        $("a.append").click(appendData);
        
        
    });
    
    var lastStudent = 23;
    var limit = 500;
    
    function appendData() {
        
        var tdTagStart = '<td>';
        var tdTagEnd = '</td>';
        var sex = ['male','female'];
        var major = ['Mathematics','Languages'];
        
        
        for(var i = 0; i < limit; i++) {
            var rnd = i % 2;
            var row = '<tr>';    
            row += tdTagStart + 'student' + (lastStudent++) + tdTagEnd;
            row += tdTagStart + major[rnd] + tdTagEnd;
            row += tdTagStart + sex[rnd] + tdTagEnd;
            
            row += tdTagStart +  randomNumber() + tdTagEnd;
            row += tdTagStart +  randomNumber() + tdTagEnd;
            row += tdTagStart +  randomNumber() + tdTagEnd;
            row += tdTagStart +  randomNumber() + tdTagEnd;
            
            row += '</tr>';
            
            $("table/tbody:first").append(row);
            
        };
        
        
        $("table").update();
        return false;
    }
    
    function randomNumber() {
        return Math.floor(Math.random()*101)
    }
    
    [removed]    
&lt;/head&gt;


&lt;body&gt;
&lt;body&gt;
<h1>Welcome to Duathlon China 2009</h1>
<p>
Good Day!
</p>
<p>
<b><font color=red>Athletes List Sortable (Submit Registration Form Successfully) - Realtime Updated </font></b>
</p>

<p>Website: <a href="http://www.duathlonchina.com" class="append">DuathlonChina.com </a>
</p>

<table id="myTable" class=tablesorter  cellSpacing=1 cellPadding=0 border=0>
<thead>
<tr>    
<th>Athlete Name/ 选手姓名</th>    
<th>Nationality / 国籍</th>    
<th>Gender / 性别</th>    
<th>Group / 参赛组别</th>    
<th>Submit Date&Time;/ 提交时间</th>
</tr> </thead>


<tbody>
&lt;?php

$db_host = 'localhost';
$db_user = 'myusername';
$db_pwd = 'mypassword';
$database = 'mydatabase';
$table = 'mytablename';

if (!mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");

if (!mysql_select_db($database))
    die("Can't select database");

$result = mysql_query("SELECT username,gender,nationality,category,regtime FROM {$table}");
if (!$result) {
    die("Query to show fields from table failed");
}
$fields_num = mysql_num_fields($result);

echo "<tr>";

for($i=0; $i<$fields_num; $i++)
{
    $field = mysql_fetch_field($result);
    echo "<td>{$field->name}</td>";
}
echo "</tr>\n";

while($row = mysql_fetch_row($result))
{
    echo "<tr>";
    // $row is array... foreach( .. ) puts every element    
    // of $row to $cell variable
   foreach($row as $cell)
       echo "<td>$cell</td>";
   echo "</tr>\n";
}
mysql_free_result($result);
?&gt;
</tbody>
</table>

[removed]
[removed]
[removed]
_uacct = "UA-2189649-1";
urchinTracker();
[removed]
&lt;/body&gt;


&lt;/html&gt;
#2

[eluser]Nano HE[/eluser]
At my CI Admin Dashboard, i could show Chinese Character Successfully.


Dashboard View File Code
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Welcome to DuathlonChina.com&lt;/title&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
&lt;link href="&lt;?= base_url();?&gt;css/style.css" rel="stylesheet" type="text/css" /&gt;

&lt;/head&gt;
&lt;body&gt;

<h1>Duathlon Shanghai 2009 Registration Result</h1>

<h2><a href="../categories/export">Export to Excel File</a></h2>
<h2><a href="../admins/logout">Logout</a></h2>

[removed]
$(document).ready(function() {    
    // call the tablesorter plugin    
    $("resultviewtable").tablesorter({        
        // sort on the first column and third column, order asc        
    sortList: [[1,0],[2,0]]     }); });
[removed]

&lt;?php

if (count($categories)){
    echo "<table class='tablesorter' border='1' cellspacing='0' cellpadding='3' width='100%' id='resultviewtable'>\n";
    echo "<tr valign='top'>\n";
    echo "<th>ID</th>\n<th>Username</th>\n<th>Email</th>\n<th>PassportID</th>\n<th>TEL/MP</th>\n<th>EmContact</th>\n<th>EmMP</th>\n<th>Nationality</th>\n<th>Gender</th>\n<th>Waiver</th>\n<th>Category</th>\n<th>RegFee</th>\n<th>Trans</th>\n<th>RegTime</th>\n";
    echo "</tr>\n";
    foreach ($categories as $key => $list){
        echo "<tr valign='top'>\n";
                
        echo "<td>".$list['id']."</td>\n";
        echo "<td>".$list['username']."</td>\n";
        echo "<td align='center'>".$list['email']."</td>\n";
                echo "<td>".$list['idno']."</td>\n";
        echo "<td>".$list['mp']."</td>\n";
        echo "<td>".$list['emuser']."</td>\n";
        echo "<td>".$list['emmp']."</td>\n";
        echo "<td align='center'>".$list['nationality']."</td>\n";
        echo "<td>".$list['gender']."</td>\n";
        echo "<td>".$list['waiver']."</td>\n";
        echo "<td align='center'>".$list['category']."</td>\n";
        echo "<td>".$list['regfee']."</td>\n";
        echo "<td>".$list['trans']."</td>\n";
        echo "<td align='center'>".$list['regtime']."</td>\n";

//        echo "<td align='center'>";
        //echo anchor('admin/admins/edit/'.$list['id'],'edit');
//                echo "edit";
//        echo "|";
        //echo anchor('admin/admins/delete/'.$list['id'],'delete');
//                echo "delete";
//        echo "</td>\n";
        echo "</tr>\n";
    }
    echo "</table>";
}

?&gt;


&lt;/body&gt;
&lt;/html&gt;
#3

[eluser]Nano HE[/eluser]
Admin Dashboard Snapshot.
#4

[eluser]pistolPete[/eluser]
Why do you post in the CodeIgniter forums when your problem is not related to CodeIgniter at all?
#5

[eluser]Nano HE[/eluser]
@pistolPete
Actually, i developed the race registration web page with CI
www.ironmanchina.net/active/index.php/form/
And i developed the Admin Dashboard with CI too.
CI Dashboard could handle DB Chinese Character very well.

I don't know how to integrate TableSorter to current web system.
So i thaked use normal HTML method.
But i meet the problem. DB Chinese Character Error.


I thought some CI fans also meet the same problem.
That's why i post here. :-)

Solution.
Reference:http://www.nixser.com/2006/08/27/solution-for-mysql-utf-8-encoded-data-unreadable-in-web-pages/
With PHPMyAdmin
Change username Type from varchar(255) to varbinary(255)
Problem resolved.




Theme © iAndrew 2016 - Forum software by © MyBB