鏈暀绋嬭浜嗕笁涓疄渚嬮兘鏄叧浜巔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>"; }
鏂囩珷缃戝潃:
闅忔剰杞浇^^浣嗚闄勪笂鏁欑▼鍦板潃銆?/p>