-----022-mysql.php-----
1<! DOCTYPE html>234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">5<title>MySQL</title>67<body>8MySQL9<pre style= "font-family: Microsoft ya black; Font-size:14pt ">Ten<?PHP One //Absolute Path! Absolute path! Absolute path! A $con= @mysql_connect("localhost", "root", "root") or die("Unable to connect to database"); - mysql_select_db("World",$con); - $sql= "Select code, name, population from country ORDER by population DESC LIMIT 5"; the $result=mysql_query($sql,$con); - Echo"Resources queried:",$result, "\ n"; - Echo"Number of results queried:", @mysql_numrows($result), "\ n"; - Echo"The third row of data:",Mysql_result($result, 0, "code"), "",Mysql_result($result, 0, "name"), "",Mysql_result($result, 0, "population"), "\ n"; + - Mysql_data_seek($result, 0);//pointer-homing + Echo"<b>mysql_fetch_row query data:</b>", "\ n"; A while(List($a,$b,$c) =Mysql_fetch_row($result)){ at Echo $a, "---",$b, "---",$c, "\ n"; - } - - Mysql_data_seek($result, 0);//pointer-homing - Echo"<B>MYSQL_FETCH_ASSOC query data:</b>", "\ n"; - while($s=Mysql_fetch_assoc($result)){ in Var_export($s); - } to Echo"\ n"; + - Mysql_data_seek($result, 0);//pointer-homing the Echo"<b>mysql_fetch_array query data:</b>", "\ n"; * while($s=Mysql_fetch_array($result,mysql_num)) { $ Echo $s[0], "",$s[1], "",$s[2]/100000000, "billion \ n";Panax Notoginseng } - the Mysql_data_seek($result, 0);//pointer-homing + Echo"<b>mysql_fetch_object query data:</b>", "\ n"; A while($s=Mysql_fetch_object($result)){ the foreach($s as $key=$value){ + printf("%s=>%-15s",$key,$value); - //echo $key, "= =", $value, "\ t"; $ } $ Echo"\ n"; - } - Echo"Error message:",Var_export(Mysql_error()), "\ n"; the Echo"Error code:",Mysql_errno(), "\ n"; -?>Wuyi</pre> the</body> -