$sql="select * from `yszl` ORDER BY id DESC"; $result=$conn->query($sql); while ($rs=mysqli_fetch_array($result)) { echo '<div class="result">'; if(($rs[fabu])=="yishi"){ echo '<ul><li><b>类别:<em>遗失</em></b></li><br />'; }else { echo '<ul><li><b>类别:<em>招领</em></b></li><br />'; } echo "<li><b>标题:</b>".$rs[title]."</li>\n"; echo "<li><b>内容:</b></br>".$rs[info]."</li></p>"; echo "<li><b>用户名:</b>".$rs[name]." - <b>QQ:".$rs[qq]."</b></a> - <b>联系电话:</b>".$rs[tel]. " - <b>发布时间:</b>".$rs[time]."</li></ul></div><br /><hr />";
最新回答
怎忘
2025-03-28 05:39:24
一:连接数据库的时候就设置. $mysqli = new mysqli($dbhost,$dbuser,$dbpass,$dbname) or die("Can not connect to the database because:".mysqli_connect_error()); //设置返回数据的字符编码! if (!$mysqli->set_charset("utf8")) { printf("Error loading character set utf8: %s\n", $mysqli->error); } else { ;//negnect //printf("Current character set: %s\n", $mysqli->character_set_name()); } 然后:在网页上也设置. 如第一个回答. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />