顯示具有 PHP 標籤的文章。 顯示所有文章
顯示具有 PHP 標籤的文章。 顯示所有文章

2015年3月31日 星期二

[PHP] 連接postgresql code

以php連接postgresql程式碼,以下『飯粒』會輸出連接的資料庫中,

所有的資料表名稱。

 <?php  
 //查出資料庫中所有的資料表  
 $sql="SELECT table_name  
  FROM information_schema.tables  
  WHERE table_schema='public'  
   AND table_type='BASE TABLE';";  
 //連接字串  
 $conn_string= "host=192.168.1.30 port=5432 dbname=TESTDB user=postgres password=mydbpw";  
 //開啟連接  
 $connection= pg_connect($conn_string);  
 //執行SQL並傳回結果  
 $myresult = pg_exec($connection, $sql);  
 //確認有回傳結果  
 if (isset($myresult))  
 {  
  //輸出所有結果  
  for ($lt=0;$lt<pg_numrows($myresult);$lt++)  
  {  
   echo pg_result($myresult,$lt,'table_name').'<br>';  
  }  
 }  
 ?>  

2015年2月13日 星期五

[PHP] 列出所有Post參數

在PHP 裡輸出所收到的所有參數
 <?php  
 foreach ($_POST as $key => $value)  
  echo "key:".htmlspecialchars($key)." vale:".htmlspecialchars($value)."  
 ";  
 ?>  

資料來源

 http://stackoverflow.com/questions/6334830/php-possible-to-automatically-get-all-posted-data