DB

php select , display 中文

July 14, 2012   ·   0 Comments

Screen Shot 2012-07-14 at 1.55.08 AM
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<?php

$user="xxxx";
$password="xxxx";
$database="xxxx";
$link=mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
mysql_query("SET NAMES 'utf8'",$link);
$query="SELECT * FROM tv_file ";

$result=mysql_query($query);

 if ($result){
 $num=mysql_num_rows($result);
 }else{
 $num=0;
 }

 echo $num;
 echo "<numFields>".mysql_num_fields($result)."</numFields>";

$numfields = mysql_num_fields($result);
 echo '<table border="1" bgcolor="white"><tr>';
 for ($i = 0; $i<$numfields; $i += 1) {
 $field = mysql_fetch_field($result, $i);
 echo '<th>' . $field->name . '</th>';
 }
 echo '</tr>';
 while ($fielddata = mysql_fetch_array($result)) {
 echo '<tr>';
 for ($i = 0; $i<$numfields; $i += 1) {
 $field = mysql_fetch_field($result, $i);
 echo '<td>' . $fielddata[$field->name] . '</td>';
 }
 echo '</tr>';
 }
 echo '</table>';
?>

&nbsp;

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
PHP98

PHP

Amazon

adsbygoogle

Recent Posts

Categories

Amazon