我有PAR_ID和列(par1-5)1表長達5,但我想有我下面的PHP函數來呼應任意數量的列如何從MySQL數據庫除了第一個在PHP中回顯列1 ... n?
//-------------------------------------- get about ----------------------------------------------
function getAbout($option){
$div = array();
$sql_st = "undefined";
if($option == "about")
$sql_st = "SELECT * FROM `about` where par_id='1'";
// connect to database
mysql_connect($_SESSION['dbSever'],$_SESSION['dbUser'],$_SESSION['dbPass']) or die(mysql_error());
mysql_select_db($_SESSION['tblName']) or die(mysql_error());
$result = mysql_query($sql_st) or die(mysql_error()."<br/>".$sql_st);
$num_rows = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)){
// not sure what to do here
}
// disconnect
mysql_close();
return $div;
}
[**請不要在新代碼中使用'mysql_ *'函數**](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in- PHP)。他們不再被維護[並被正式棄用](https://wiki.php.net/rfc/mysql_deprecation)。使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/mysqli) - [這篇文章](http://php.net/manual/en/mysqlinfo。 api.choosing.php)將幫助你決定哪個。如果你選擇PDO,[這裏是一個很好的教程](http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers)。 – misterManSam 2014-08-28 13:01:09
謝謝。我會記住 – PiboRock 2014-08-28 13:04:58