當前位置:首頁 » 編程語言 » php讀取資料庫

php讀取資料庫

發布時間: 2022-01-12 17:16:59

php+mysql php怎麼讀取mysql資料庫的數據!

其實這里跟你講了也講不全。


推薦你看看韓順平的php零基礎教程


這段視頻已經公開在網上,網路一下就有了,你把mysql的內容過一邊就會了。

② PHP 讀取資料庫數組。。。

$sql='selectid,listfromxxx';
$res=mysql_query($sql);
echo'<table><tr><th>ID<th>list';
while(list($id,$list)=mysql_fetch_row($res)){
$str="<inputtype=checkbox>";
$str.=implode($str,explode(',',$list));
echo"<td><td>$id<td>$str";
}
mysql_free_result($res);
echo'</table>';

③ php sql讀取資料庫

<?php
$str=$_GET['b'];
$sql = "SELECT * FROM `zz` where b=$str";
$results=mysql_query($sql);
while($row = mysql_fetch_array($results)) {
echo($row['a']."<br>");
}
?>

④ 怎麼用php讀取資料庫內容並輸出

讀取內容一般使用select語句,輸出的話方法比較多,具體的可以參考網上的教程,根據自己的實際需要來選用其中一種,一般都是把數據讀取到一個數組參數裡面,然後再輸出這個數組內容。具體的可以參考下w3school的教程:http://www.w3school.com.cn/php/php_mysql_select.asp

⑤ php如何通過讀取資料庫

1.在對象資源管理器中,連接到
SQL
Server
資料庫引擎實例,再展開該實例。
2.右鍵單擊「SQL
Server
代理」,再單擊「屬性」。
3.在「SQL
Server
代理屬性」對話框中,單擊「連接」,然後在「SQL
Server
連接」下執行以下操作:

⑥ php+mysql如何讀取資料庫數據

先配置資料庫------連接資料庫--------選擇資料庫--------填寫檢索表-------輸出檢索內容

⑦ 用php怎樣從資料庫中直接讀取數據下載

你能存進資料庫,說明你就能取數據.將取出的數據進行base64_decode,然後再根據文件格式發出一個http head,再直接echo出去.
如:一個jpg的圖片.經過header後瀏覽器就會認為那是一個圖片了.
//$db_img 這個是從資料庫取出的base64編碼格式的二進制圖片數據.
$img = base64_decode($db_img);
header("Content-type: image/jpg");
echo $img;

其他格式的文件類型就根據實際情況改header裡面的Content-type

⑧ PHP讀取MySQL

<?php

/* Connect to a MySQL server 連接資料庫伺服器 */$link = mysqli_connect(
'localhost', /* The host to connect to 連接MySQL地址 */
'root', /* The user to connect as 連接MySQL用戶名 */
'', /* The password to use 連接MySQL密碼 */
'xsgl'); /* The default database to query 連接資料庫名稱*///加上下面這行,解決中文亂碼
//$link->query("SET NAMES 'gb2312'");
$link->query("SET NAMES 'gbk'");

if (!$link) {
printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
exit;
}//插入數據
$query="insert into student(name,Sex,Birthday,Address,Email) values('劉德華','男','1966-12-12','杭州市總統路18號','[email protected]')";
mysqli_query($link,$query);

//更新數據
$query="update student set name='張學友' where Name='劉德華'";
mysqli_query($link,$query);

//刪除數據
$query="delete from student where Name='張學友'";
mysqli_query($link,$query);
//讀取所有數據 if ($result = mysqli_query($link, 'SELECT * FROM student')) {

print("查詢結果: ".'<br>');

/* Fetch the results of the query 返回查詢的結果 */
while( $row = mysqli_fetch_assoc($result) ){
printf("%s %s %s %s %s", $row['Name'],$row['Sex'],$row['Birthday'], $row['Address'],$row['Email'].'<br>');
}

/* Destroy the result set and free the memory used for it 結束查詢釋放內存 */
mysqli_free_result($result);
}

/* Close the connection 關閉連接*/
mysqli_close($link);
?>

⑨ PHP 讀取多條資料庫中數據

拿下面這段單獨建個頁面,改一下你的資料庫名,表等信息試試。

<table width="50%" border="0">
<tr>
<td>ID</td>
<td>ID2</td>
<td>order1</td>
<td>order2</td>
<td>order3</td>
</tr>
<?php
//連接資料庫
$conn=@ mysql_connect("伺服器地址","用戶名","密碼") or die("連接資料庫失敗!");
mysql_select_db("資料庫名",$conn) or die("連接資料庫失敗!");
mysql_query("set names 'GBK'");
//連接結束

//接收提交過來查詢的ID
$id=$_POST["id"];
//查詢資料庫相關數據
$sql="select * from 數據表名 where ID2='".$id."' order by id desc";
$query=mysql_query($sql);
//循環輸出
while($row=mysql_fetch_array($query)){
?>
<tr>
<td><?php echo $row["ID"];?></td>
<td><?php echo $row["ID2"];?></td>
<td><?php echo $row["order1"];?></td>
<td><?php echo $row["order2"];?></td>
<td><?php echo $row["order3"];?></td>
</tr>
<?php
}
?>
</table>
<form name="form1" method="post" action="">
<input type="text" name="id">
<input type="submit" name="Submit" value="查詢">
</form>

熱點內容
上傳文件文件夾找不到 發布:2024-09-20 00:26:32 瀏覽:914
承台箍筋加密區 發布:2024-09-20 00:26:31 瀏覽:227
筆記本什麼配置能流暢運行cf 發布:2024-09-20 00:14:19 瀏覽:951
實測華為編譯器 發布:2024-09-19 23:50:52 瀏覽:821
linux匯總 發布:2024-09-19 23:46:39 瀏覽:452
阿里雲伺服器環境搭建教程 發布:2024-09-19 23:21:58 瀏覽:837
黃色文件夾圖標 發布:2024-09-19 23:19:22 瀏覽:684
mysql資料庫導出導入 發布:2024-09-19 23:00:47 瀏覽:183
lua腳本精靈 發布:2024-09-19 23:00:41 瀏覽:659
任務欄文件夾圖標 發布:2024-09-19 22:54:25 瀏覽:101