国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

PostgreSQL連接數據的方法和操作實例

2024-05-04 21:49:25
字體:
來源:轉載
供稿:網友
  1. $pg=@pg_connect("host=localhost user=postgres password=sa dbname=employes"
  2. or die("can't connect to database."); 
  3. $query="select * from employes order by serial_no"
  4. //$query="insert into employes values(10008,'susan','1985-09-04','80','50')"; 
  5. $result=@pg_query($pg,$queryor die("can't run query to table."); 
  6. //echo pg_num_rows($result); //輸出多少條記錄被查詢 
  7. //if($result) 
  8. //{ 
  9. //echo "recrods inserted sucessfully!"; 
  10. //echo pg_affected_rows($result);//輸出多少條記錄被插入 
  11. //} 
  12. //實例一[pg_fetch_row] 
  13. echo "<table border=1>"
  14. echo "<tr>"
  15. echo "<td>serial_no</td>"
  16. echo"<td>name</td>"
  17. echo"<td>birthday</td>"
  18. echo"</tr>"
  19. for($i=0;$i<pg_num_rows($result);$i++) 
  20. $row=@pg_fetch_row($resultor die("can't fetch row from table."); 
  21. $serial_no$row[0]; 
  22. $name$row[1]; 
  23. $birthday$row[2]; 
  24. echo"<tr>"
  25. echo"<td>$serial_no</td>"
  26. echo"<td>$name</td>"
  27. echo"<td>$birthday</td>"
  28. echo"</tr>"
  29. echo"</table>"
  30. //實例二[pg_fetch_array] 
  31. //echo "<table border=1>"; 
  32. //echo "<tr>"; 
  33. //echo "<td>serial_no</td>"; 
  34. //echo"<td>name</td>"; 
  35. //echo"<td>birthday</td>"; 
  36. //echo"</tr>"; 
  37. // 
  38. //for($i=0;$i<pg_num_rows($result);$i++) 
  39. //{ 
  40. // 
  41. //$row=@pg_fetch_array($result) or die("can't fetch row from table."); 
  42. //$serial_no= $row['serial_no']; 
  43. //$name= $row['name']; 
  44. //$birthday= $row['birthday']; 
  45. //echo"<tr>"; 
  46. //echo"<td>$serial_no</td>"; 
  47. //echo"<td>$name</td>"; 
  48. //echo"<td>$birthday</td>"; 
  49. //echo"</tr>"; 
  50. // 
  51. //} 
  52. //echo"</table>"; 
  53. //增加,刪除,修改實例 
  54. //$newrow=array("serial_no"=>"1006","name"=>"peter","birthday"=>"1990-07-03","salary"=>"90","bonus"=>"80"); 
  55. //$reusult=@pg_insert($pg,"employes",$newrow) or die("can't insert data to table.");//開源代碼Vevb.com 
  56. //if($reusult) 
  57. //{ 
  58. //echo "rechords inserted sucessfully!"; 
  59. //} 
  60. // 
  61. pg_close($pg);

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 广安市| 民丰县| 基隆市| 泰来县| 定安县| 平罗县| 清丰县| 阿勒泰市| 正定县| 驻马店市| 卢龙县| 大城县| 杭锦旗| 方山县| 应用必备| 三江| 富宁县| 太湖县| 抚顺县| 新营市| 吉木乃县| 定边县| 贵溪市| 余庆县| 栾城县| 利津县| 柳江县| 轮台县| 敖汉旗| 乐业县| 广元市| 革吉县| 八宿县| 珲春市| 岳阳县| 永济市| 兴安盟| 德阳市| 肃南| 台州市| 达孜县|