如题所述
读æ°æ®åºï¼ä»¥è¡¨æ ¼è¾åºç示ä¾ä»£ç ï¼
<?php
header('Content-type:text/html;charset=utf-8');
$db = new mysqli('localhost','root','root','books');
$rows = $db->query('SELECT * FROM customers');
echo '<table border="1"><tr><td>å§å</td><td>å¹´é¾</td></tr>';
while($row = $rows->fetch_assoc()){
echo '<tr><td>'.$row['name'].'</td>';
echo '<td>'.$row['address'].'</td></tr>';
}
?追é®
<?php
header('Content-type:text/html;charset=utf-8');
$db = new mysqli('localhost','root','root','books');
$rows = $db->query('SELECT * FROM customers');
echo '<table border="1"><tr><td>å§å</td><td>å¹´é¾</td></tr>';
while($row = $rows->fetch_assoc()){
echo '<tr><td>'.$row['name'].'</td>';
echo '<td>'.$row['address'].'</td></tr>';
}
?追é®
è½è¯´è¯´ä»ä¹ä»£ç æ¯å¹²å¥çå
追çquery('SELECT * FROM customers'); //ç¨sqlè¯å¥è·åæ°æ®
echo 'å§åå¹´é¾'; //è¾åºè¡¨æ ¼æ é¢
while($row = $rows->fetch_assoc()){ //è¾åºæ°æ®åºä¸ºè¡¨æ ¼å
容
echo ''.$row['name'].'';
echo ''.$row['address'].'';
}
?
温馨提示:答案为网友推荐,仅供参考
第1个回答 2012-05-24
$dbhost = "localhost";//IP
$dbuser = "root";//账号
$dbpassword = "123456";//密码
$dbdatabase = "abc";//数据库
$db = mysql_connect($dbhost, $dbuser, $dbpassword);
mysql_select_db($dbdatabase, $db);
$sql = "SELECT * FROM d ";
$res = mysql_query($sql);
while($arr = mysql_fetch_row($res){ //也可以用mysql_fetch_object
echo $arr[0].$arr[1].$arr[2];//有多少个字段就输出多少
}
$dbuser = "root";//账号
$dbpassword = "123456";//密码
$dbdatabase = "abc";//数据库
$db = mysql_connect($dbhost, $dbuser, $dbpassword);
mysql_select_db($dbdatabase, $db);
$sql = "SELECT * FROM d ";
$res = mysql_query($sql);
while($arr = mysql_fetch_row($res){ //也可以用mysql_fetch_object
echo $arr[0].$arr[1].$arr[2];//有多少个字段就输出多少
}
第2个回答 2012-05-24
查询出来 输出