开发者

MySQL Text formatting

Hej guys,

I wrote a little php script which access a database and simply displays the rows which where found for a given query. It echos a table with them but it seems there are some typeset errors resulting in questionsmarks. Any hint what I could do to solve this? Here's a screenshot: Text Formatting">

Here's the code I'm using to fetch and display the data

$result = mysql_query($sql);
        if(mysql_num_rows($result)>0){
            echo "<div style='float:top;clear:both;'>";
            echo "<table border='1'>";
            echo "<th>id</th><th>project</th><th>publisher</th><th>country</th><th>contact</th><th>mail</th><th>agent</th><th>report</th><th>todo</th><th>by who</th><th>done(date,text)</th><th>priority</th>";
            while($row = mysql_fetch_array($result)){
                echo "<tr>";
                echo "<td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td><td>".$row[3]."</td><td>".$row[4]."</td><td>".$row[5]."</td><td>".$row[6]."</td><td>".$row[7]."</td><td>".$row[8]."</td><td>".$row[9]."</td><td>".$row[10]."</td><td>".$row[11]."</td>";
                echo "<td><form method='POST' action='insert.php'><input type='submit' name='edit' value='edit'/><input type='hidden' name='hiddenID' value='".$row[0]."' /><input type='hidden' name='hiddenDB' value='".$_POST['db']."' /><input type='hidden' name='hiddenProject' value='".$row[1]."' /><input type='hidden' name='hiddenPublisher' value='".$row[2]."' /><input type='hidden' name='hiddenCountry' value='".$row[3]."' /><input type='hidden' name='hiddenContact' value='".$row[4]."' /><input type='hidden' name='hiddenMail' value='".$row[5]."' /><input type='hidden' name='hiddenAgent' value=开发者_运维百科'".$row[6]."' /><input type='hidden' name='hiddenReport' value='".$row[7]."' /><input type='hidden' name='hiddenTodo' value='".$row[8]."' /><input type='hidden' name='hiddenBywho' value='".$row[9]."' /><input type='hidden' name='hiddenDone' value='".$row[10]."' /><input type='hidden' name='hiddenPriority' value='".$row[11]."' /></form></td>";
                echo "</tr>";
            }
            echo "</table>";
            echo "</div>";

p.s.: It seems special chars like the german "ß" also aren¿t getting inserted properly into the database when I inspect the datasets using phpmyadmin


I suggest you to use UTF-8 charset.

You should make your table/colunmn charset to utf8_general_ci

And then in your PHP script launch as first query

SET NAMES 'utf-8'


as for displaying data, same issue for cyrillic chars is solved by running next code before getting data from DB:

 mysql_query ("set character_set_client='cp1251'"); 
 mysql_query ("set character_set_results='cp1251'"); 
 mysql_query ("set collation_connection='cp1251_general_ci'");

Use appropriate german charset for your case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜