天天看點

html連接配接到mysql資料庫_怎麼連接配接HTML網頁到資料庫?

??涔?杩???TML缃?椤靛?版?版??搴?锛?

??甯??堕?達?2020-07-11 15:46:08

?ユ?锛?浜塊??浜?

??璇夥?448

浣???锛?Leah

??绡???绔?涓哄ぇ瀹跺?绀轟???涔?杩???TML缃?椤靛?版?版??搴?锛?浠g??绠????艱?骞朵?瀹規????瑙o?缁?瀵矽?戒嬌浣??煎??涓?浜?锛???杩?杩?绡???绔???璇??浠?缁?甯???浣??芥?????惰?楓??

HTML????娉?璇誨???版??搴???锛?HTML??椤甸?㈠??绔?????璇?瑷?锛?瑕??充?HTML缃?椤典腑?峰??SQL?版??搴??????版??锛???瑕?????SP??ASP??PHP??RUBY绛?璇?瑷??ュ???般?? 绠??????崇郴??浠ヨ??風??瑙o? ?版??搴?JSP??ASP??PHP??RUBY绛?璇?瑷?HTML

缃?椤甸?炬?ユ?版??搴?浠g??濡?涓?(PHP缂???)锛?<?php

header('content-type:text/html;charset=gb2312;');//瑙e?蟲?瑙??ㄧ?????棰?

$lnk = mysql_connect('localhost', 'root', '********') or die ('杩??ュけ璐?: ' . mysql_error());//瀵???濉?????杩??ユ?版??搴???瀵???

mysql_query("set names gb2312");//杩?灏辨????瀹??版??搴?瀛?绗???

//???╁???杩??ユ?版??搴?涓?tudent

mysql_select_db('book', $lnk);

//?峰???ヨ?㈤」???ヨ?㈠?抽??瀛?????

$searchitem=$_POST['searchitem'];

$searchvalue=$_POST['searchvalue'];

if($searchvalue!="")

$myquery="SELECT * from books where {$searchitem} like '%{$searchvalue}%'";

else

$myquery="SELECT * from books";

//?ц??ヨ???????缁?????

$result = mysql_query($myquery)or die("

?ヨ?㈣〃books澶辮觸: " . mysql_error());

//浠?缁?????涓???寰?涓?琛?浣?涓哄?寵???扮?

$row=mysql_fetch_array($result);

//寰???璇誨??姣?涓?琛?璁闆?

while ($row)

{

}

?>

涓?杩闆??瀹瑰氨????涔?杩???TML缃?椤靛?版?版??搴?锛?锛?浣?浠?瀛??扮?ヨ???????戒???锛?濡???杩??沖???版?村????芥????涓闆????宸辯???ヨ???ㄥ?锛?娆㈣??蟲敞浜塊??浜?琛?涓?璧?璁?棰?????