html 通過php調用MySQL

你用POST方式傳值,必須要有個表單,表單提交數據後,要echo出變數才能看到,

你把$xuehao=$_POST["id"];下面加個echo $xuehao;就可以看到輸出了,在php結束標記?>後面加上一段代碼
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form action="index.php" method="post">
<table>
<tr><td>學號</td> <td><input type="text" name="id"></td></tr>
<tr><td>姓名</td><td><input type="text" name="name"></td></tr>
<tr><td>性別</td><td><input type="text" name="sex"></td></tr>
<tr> <td></td><td><input type="submit" value="提交"></td></tr>
</table>

</form>

</body>

</html>

② 高分 html頁面如何顯示PHP資料庫裡面的東西.

你可以讓html提用函數,你用JS好的話更簡單`
要是我我就用php函數
<?php function wewe(){
include("../config.php")
mysql_conncet(.....);//連接資料庫取出數據直接放在函數里
$result=mysql_query("select * from....");
$str='<table><tr><td>';
while($row=mysql_fetch_array($result)){

$str.='$row[name]';

}
$str.='</td></tr></table>';
return $str;
}
?>
好好看看函數的功能,想輸出什麼就改成什麼
然後引用這個函數就可以在html動態的顯示資料庫里的內容了

③ 如何通過PHP把html的表單提交到mysql資料庫

首先,你得在diaocha.php這個文件,接收表單傳的值

$radiogroup = isset($_POST['radiogroup'])?$radiogroup:''

isset用來檢測是否有選中提交,然後就是資料庫版的鏈接

$con = mysql_connect('localhost','root',''); //三個參數,分別權是,連接的主機名,mysql的賬號,mysql密碼
mysql_query('set names utf8'); //設置連接的字元集,如果頁面是utf8的編碼,就是utf8,如果是gbk的話,那就寫 set names gbk
mysql_select_db('xxx',$con);&nbsp; //xxx就是你要選擇的資料庫名稱

插入數據

$sql = "insert into xxxx set xxx = $radiogroup" //xxxx 是你要插入的表名,xxx就是欄位名
mysql_query($sql);

④ 如何通過html和php調用my sql資料庫

PHP不會用Mysql簡直......
html文件里用
<form>
....
</form>
將資料post到php文件
然後處理數據

怎麼連MYSQL,自己去搜索,你用網路得到的結果一年也看不完

搜索"php 連接 Mysql"

去吧,要勤快點,自己去查,實在查不到再問

http://www..com/s?ie=gb2312&bs=QDIPC+%C3%E2%B7%D1DNS&sr=&z=&cl=3&f=8&wd=php+%C1%AC%BD%D3+Mysql&ct=0

⑤ 怎麼在html中寫PHP代碼,前台頁面從後台資料庫中取值,

方法如下

1、把$user的值賦值給全局數組。

2、header("Location: index.html"); 在這個代碼傳參數到index.html頁面,index頁面改成index.php

php代碼可以寫在html代碼中的任意部分,只要帶上<? ?> 界定標簽就好了和平時寫php沒有任何區別。

但是需要注意的一點是,這個文件的後綴名要是 .php 的,所以更准確的說法應該是html寫在了PHP文件中,這並不影響我們同時使用這兩種語言 。

實例

<?php

//連接資料庫

$link = mysql_connect("localhost", "username", "password")

or die("Could not connect: " . mysql_error());

print ("Connected successfully");

//選擇資料庫

mysql_select_db('dbname', $link) or die ('Can't use db : ' . mysql_error());

//進行你想要的操作

$a =123;

?>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>發現I Do一刻</title>

<link href="css/public.css" rel="stylesheet" type="text/css">

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

</head>

<body>

<?php

echo $a;

?>

</body>

</html>

用echo 直接輸出到 頁面上就好了

(5)htmlphp資料庫擴展閱讀

集成開發環境是一種集成了軟體開發過程中所需主要工具的集成開發環境,其功能包括但不僅限於代碼高亮、代碼補全、調試、構建、版本控制等。一些常見的PHP IDEs如下:

1、Zend Studio:商業版,Zend官方出品,基於eclipse

2、Eclipsewith PDT:免費

3、Coda:商業版,針對Mac用戶

4、NetBeans:免費,功能強大

5、PHP Storm:商業版

6、AptanaStudio:免費

7、PhpEd:商業版

8、KomodoIDE/Edit:IDE為商業版,Edit可免費使用

9、Adobe Dreamweaver:商業版

除去集成開發環境,具備代碼高亮功能的常見文本編輯器因其輕巧靈活也常被選作開發工具,例如:Notepad++、Editplus、SublimeText、Everedit(國人開發)等等。

⑥ 怎麼用php把html表單內容寫入資料庫

1:首先要使用PHP的超全局變數 $_GET 和 $_POST 用於收集表單數據(form-data)

2:然後使用INSERT INTO 語句用於向資料庫表中插入新記錄。

具體示例:

(1)首先創建了一個名為 "Persons" 的表,有三個列:"Firstname", "Lastname" 以及 "Age"。

<?php
$con=mysql_connect("localhost","peter","abc123");
if(!$con)
{
die('Couldnotconnect:'.mysql_error());
}

mysql_select_db("my_db",$con);

mysql_query("INSERTINTOPersons(FirstName,LastName,Age)
VALUES('Peter','Griffin','35')");

mysql_query("INSERTINTOPersons(FirstName,LastName,Age)
VALUES('Glenn','Quagmire','33')");

mysql_close($con);
?>

(2)其次創建一個 HTML 表單,這個表單可把新記錄插入 "Persons" 表。

<html>
<body>

<formaction="insert.php"method="post">
Firstname:<inputtype="text"name="firstname"/>
Lastname:<inputtype="text"name="lastname"/>
Age:<inputtype="text"name="age"/>
<inputtype="submit"/>
</form>

</body>
</html>

(3)接著當用戶點擊上例中 HTML 表單中的提交按鈕時,表單數據被發送到 "insert.php"。"insert.php" 文件連接資料庫,並通過
$_POST 變數從表單取回值。然後,mysql_query() 函數執行 INSERT INTO 語句,一條新的記錄會添加到資料庫表中。

<?php
$con=mysql_connect("localhost","peter","abc123");
if(!$con)
{
die('Couldnotconnect:'.mysql_error());
}

mysql_select_db("my_db",$con);

$sql="INSERTINTOPersons(FirstName,LastName,Age)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";

if(!mysql_query($sql,$con))
{
die('Error:'.mysql_error());
}
echo"1recordadded";

mysql_close($con)
?>

⑦ php從資料庫里讀出的HTML代碼然後執行怎麼實現

<?php require_once("mysql_class.php");
require_once("sys_conf.inc");
header('Content-Type:text/html;Charset=GBK;');
$link_id=mysql_connect($DBHOST,$DBUSER,$DBPWD);
mysql_select_db($DBNAME); //選擇資料庫my_chat
$sql="SELECT * FROM `dx_leibie`";
$query = mysql_query($sql);
while($row=mysql_fetch_array($query)){
//print_r($row); //$con=array(array('新聞標題','新聞內容'),array('新聞標題2','新聞內容2')); $title=$row[id_lang];
$content=$row[name];
if(!is_dir("up")) //如果此文件夾不存在,則自動建立一個
{
mkdir("up");
}$up="up/";
echo $path=$up.$row[id_lang].'.htm';
$fp=fopen("tmp.htm","r"); //只讀打開模板
$str=fread($fp,filesize("tmp.htm"));//讀取模板中內容
$str=str_replace("{title}",$title,$str);
echo $str=str_replace("{content}",$content,$str);//替換內容
fclose($fp); $handle=fopen($path,"w"); //寫入方式打開新聞路徑
fwrite($handle,$str); //把剛才替換的內容寫進生成的HTML文件
fclose($handle);
//echo "生成成功";
} // unlink($path); //刪除文件
?><?php require_once("mysql_class.php");
require_once("sys_conf.inc");
header('Content-Type:text/html;Charset=GBK;');
$link_id=mysql_connect($DBHOST,$DBUSER,$DBPWD);
mysql_select_db($DBNAME); //選擇資料庫my_chat
$sql="SELECT * FROM `dx_leibie`";
$query = mysql_query($sql);
while($row=mysql_fetch_array($query)){
//print_r($row); //$con=array(array('新聞標題','新聞內容'),array('新聞標題2','新聞內容2')); $title=$row[id_lang];
$content=$row[name];
if(!is_dir("up")) //如果此文件夾不存在,則自動建立一個
{
mkdir("up");
}$up="up/";
echo $path=$up.$row[id_lang].'.htm';
$fp=fopen("tmp.htm","r"); //只讀打開模板
$str=fread($fp,filesize("tmp.htm"));//讀取模板中內容
$str=str_replace("{title}",$title,$str);
echo $str=str_replace("{content}",$content,$str);//替換內容
fclose($fp); $handle=fopen($path,"w"); //寫入方式打開新聞路徑
fwrite($handle,$str); //把剛才替換的內容寫進生成的HTML文件
fclose($handle);
//echo "生成成功";
} // unlink($path); //刪除文件
?><?php require_once("mysql_class.php");
require_once("sys_conf.inc");
header('Content-Type:text/html;Charset=GBK;');
$link_id=mysql_connect($DBHOST,$DBUSER,$DBPWD);
mysql_select_db($DBNAME); //選擇資料庫my_chat
$sql="SELECT * FROM `dx_leibie`";
$query = mysql_query($sql);
while($row=mysql_fetch_array($query)){
//print_r($row); //$con=array(array('新聞標題','新聞內容'),array('新聞標題2','新聞內容2')); $title=$row[id_lang];
$content=$row[name];
if(!is_dir("up")) //如果此文件夾不存在,則自動建立一個
{
mkdir("up");
}$up="up/";
echo $path=$up.$row[id_lang].'.htm';
$fp=fopen("tmp.htm","r"); //只讀打開模板
$str=fread($fp,filesize("tmp.htm"));//讀取模板中內容
$str=str_replace("{title}",$title,$str);
echo $str=str_replace("{content}",$content,$str);//替換內容
fclose($fp); $handle=fopen($path,"w"); //寫入方式打開新聞路徑
fwrite($handle,$str); //把剛才替換的內容寫進生成的HTML文件
fclose($handle);
//echo "生成成功";
} // unlink($path); //刪除文件
?> 用以上先生成一個HTML文件,然後再用require_once("aaa.html");引進來就OK

⑧ 怎樣藉助PHP從HTML網頁中獲取phpmyadmin資料庫里數據表的內容

<?php
$link=mysql_connect('localhost','用戶名','密碼')ordie("資料庫連接失敗");//連接資料庫
mysql_select_db('資料庫名',$link);//選擇資料庫
mysql_query("setnamesutf8");//設置編碼格式
$q="select*from"數據表";//設置查詢指令
$result=mysql_query($q);//執行查詢
while($row=mysql_fetch_assoc($result))//將result結果集中查詢結果取出一條
{echo返回到HTML;}
?>

html界面使用ajax的成功返回值,再渲染在界面里就行了

⑨ html怎麼用php連接資料庫

用php連接資料庫:
mysql資料庫
$conn = mysql_connect('localhost','root','111111');//括弧的里的分別代表主機、用戶名、密碼
mysql_select_db('資料庫回名',$conn);//選擇庫
mysql_query('set names gbk',$conn);//設置字元答集

⑩ php如何把html代碼存入mysql資料庫呀

我覺得你還是保存頁面的路徑得了。。。
需要用的時候 echo'<iframe.......>'; 吧