Home > php教程 > php手册 > php mysql鏁版嵁搴撴搷浣滄暀绋?- PHP鍏ラ棬

php mysql鏁版嵁搴撴搷浣滄暀绋?- PHP鍏ラ棬

WBOY
Release: 2016-05-26 15:21:58
Original
2154 people have browsed it

鏈暀绋嬭浜嗕笁涓疄渚嬮兘鏄叧浜巔hp鎿嶄綔mysql鏁版嵁搴撶殑鏁欑▼,涓€鏄繛鎺ysql鏁版嵁搴?浜屾槸鏌ヨ鏁版嵁搴撳瓧娈靛悕瀛?涓夋槸鏌ヨ鏁版嵁搴撹褰?

杩炴帴mysql鏁版嵁搴?浠g爜濡備笅:

$link = mysql_connect("localhost", "mysql_user", "mysql_password") 
or die("could not connect: " . mysql_error()); 
print ("connected successfully"); 
mysql_close($link); 
鏌ヨmysql瀛楁鍚?浠g爜濡備笅:
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); 
$fields = mysql_list_fields("database1", "table1", $link); 
$columns = mysql_num_fields($fields); 
for ($i = 0; $i < $columns; $i++) { 
echo mysql_field_name($fields, $i) . " "; 
} 
鏌ヨ鏁版嵁,浠g爜濡備笅:
$conn=mysql_connect("localhost","phpdb","phpdb") 
or die("涓嶈兘杩炴帴鏁版嵁搴撴湇鍔″櫒锛?nbsp;".mysql_error());  
mysql_select_db("test",$conn) or die ("涓嶈兘閫夋嫨鏁版嵁搴? ".mysql_error());  
$result = mysql_query("select * from user",$conn); 
while($row=mysql_fetch_array($result)){  
print "name:".$row[1];
print " address:".$row[3];  
print " tel:".$row[4];  
print " email:".$row[5]; 
echo 
"<br>"; 
}
Copy after login


鏂囩珷缃戝潃:

闅忔剰杞浇^^浣嗚闄勪笂鏁欑▼鍦板潃銆?/p>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template