當前位置:首頁 » 參考文獻 » php顯示資料庫數據

php顯示資料庫數據

發布時間: 2021-01-25 01:40:05

⑴ php如何在頁面簡單調用資料庫內容顯示出來

(1)沒錯
(2)你沒選資料庫好不好
mysql_select_db($database);

⑵ PHP 怎麼顯示資料庫中的數據 求源代碼

讀資料庫,以表格輸出的示例代碼:

<?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查詢資料庫里的一個數據並顯示

面向過程:
$sql = "select t_bumen from t_xinxi where id=111"; //Sql語句

$result = mysql_fetch_assoc(mysql_query($sql)); //執行sql語句並以關聯數組保存

print_r($result); //輸出數組

⑷ php讀取mysql,如何以表格顯示數據

<?php
//設置編碼格式
header("Content-type:text/html;charset=utf-8");
//鏈接資料庫
$conn = mysql_connect("localhost","root","");
//選擇要操作的資料庫
mysql_select_db('act1',$conn);
//設置版操作資料庫編碼權格式
mysql_query("set names utf8");
//執行查詢操作
$re= mysql_query("select user_name,phone from user");
?>
<table border='1px'>
<!-- 表格頭部 -->
<tr>
<td>用戶名</td><td>電話</td>
</tr>
<?php
//每循環一次,取一行數據記錄顯示在一行中
while($row=@mysql_fetch_row($re)){
?>
<tr>
<td><?php echo $row[0];?></td><td><?php echo $row[1];?></td>
</tr>
<?php
}
?>
</table>

⑸ php怎麼把資料庫中的數據顯示成表格

你用phpexcel類吧,不過要生成你這樣的表格,貌似不簡單。

⑹ php怎麼把資料庫的數據顯示到頁面上

如果是mysql的話回
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
if (!答$link) {
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
exit();
}
$result = mysqli_query($link, "SELECT CountryCode FROM Language");
printf("Affected rows (SELECT): %d\n", mysqli_affected_rows($link));
mysqli_free_result($result);
mysqli_close($link);

⑺ 很簡單的一個小功能,php讀取資料庫中的數據,並顯示在網頁上

首先是一個input class=dh
查詢按鈕 class=cx
圖片框 class=tp
點擊查詢按鈕時
<script>
$(".cx").click(function(){
var dh= $('.dh').val();//獲取輸入的電話
$.post('date.php',{tel:dh},function(result){
//將獲取到的電話號碼提交給date.php文件,date.php文件 通過查詢tel='$_POST[tel]' 得到圖片地址$src,echo $src;result即使那個返回的$src
$('.tp').find('img').attr('src', result);//將圖片框內容改掉
});
});
</script>
需要jquery支持 就是頁面要載入
<script type="text/javascript" src="js/jquery.js"></script>

⑻ 如何用php獲取資料庫信息並顯示

獲取ppq資料庫的所有表名的代碼:
?php
$server='localhost';
$user='root';
$pass='12345';
$dbname='ppq';
$conn=mysql_connect($server,$user,$pass);
if(!$conn)
die("資料庫系統連接失敗!");
$result=mysql_list_tables($dbname);
if(!$result)
die("資料庫連接失敗!");
while($row=mysql_fetch_row($result))
{
echo
$row[0]."
";
}
mysql_free_result($result);
?
mysql_list_tables
(PHP
3,
PHP
4
,
PHP
5)
mysql_list_tables
--
列出
MySQL
資料庫中的表
說明
resource
mysql_list_tables
(
string
database
[,
resource
link_identifier])
mysql_list_tables()
接受一個資料庫名並返回和
mysql_query()
函數很相似的一個結果指針。用
mysql_fetch_array()或者用mysql_fetch_row()來獲得一個數組,數組的第0列就是數組名,當獲取不到時
mysql_fetch_array()或者用mysql_fetch_row()返回
FALSE。

⑼ PHP 怎麼顯示資料庫中的數據 求源代碼

讀資料庫,以表格輸出的示例代碼:專
<?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如何查詢資料庫表中的數據並顯示

這個簡單啊!
首頁做個前台輸入姓名和會員卡信息的頁面,我做個簡單的頁面給你看

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""
<htmlxmlns="
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>會員查詢系統</title>
</head>

<body>
<formid="form1"name="form1"method="post"action="test.php">
<p>
<labelfor="name"></label>
<inputtype="text"name="name"id="name"/>
</p>
<p>
<labelfor="vipid"></label>
<inputtype="text"name="vipid"id="vipid"/>
</p>
<p>
<inputtype="submit"name="button"id="button"value="查詢"/>
</p>
</form>
</body>
</html>
然後我給你一個test.php的文件代碼:
<?php
$name=trim($_POST['name']);
$vipid=trim($_POST['vipid']);
$con=mysql_connect("127.0.0.1","資料庫用戶名","資料庫密碼");
if(!$con)
{
die('Couldnotconnect:'.mysql_error());
}
$a=mysql_select_db("資料庫名字",$con);
$sql="select*fromkh_customerwherename='$name'andvipid='$vipid'";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo$row['name']."".$row['data'];
echo"<br/>";
}
mysql_close($con);
?>

頁面美化自己去搞!只能幫你這么多了

熱點內容
塗鴉論文 發布:2021-03-31 13:04:48 瀏覽:698
手機資料庫應用 發布:2021-03-31 13:04:28 瀏覽:353
版面217 發布:2021-03-31 13:04:18 瀏覽:587
知網不查的資源 發布:2021-03-31 13:03:43 瀏覽:713
基金贖回參考 發布:2021-03-31 13:02:08 瀏覽:489
懸疑故事範文 發布:2021-03-31 13:02:07 瀏覽:87
做簡單的自我介紹範文 發布:2021-03-31 13:01:48 瀏覽:537
戰略地圖參考 發布:2021-03-31 13:01:09 瀏覽:463
收支模板 發布:2021-03-31 13:00:43 瀏覽:17
電氣學術會議 發布:2021-03-31 13:00:32 瀏覽:731