我不能從MySQL數據庫中獲取多行到數組?我有代碼,但它不工作或不顯示所有行時,我回聲到文本框?我不能從MySQL數據庫獲取多行到數組?
<?php
if(is_array($_SESSION['pid']))
{
$pid = join(',',$_SESSION['pid']);
$result=mysql_query("SELECT id AS wid FROM mywishlist where pid='$pid'")
or die("Id Problem"."<br/><br/>".mysql_error());
$results= array();
$i=0; // add the new line
while($row=mysql_fetch_array($result)){
$results[$i] = $row['wid'];
$i++;
}
$results;
}
$max=count($results);
for($j=0; $j<$max; $j++)
{
?>
<input type="text" name="wid[]" value="<?php echo $results[$j]; ?>" />
<?php } ?>
[**在新的代碼,請不要使用'mysql_ *'功能**](http://bit.ly/ phpmsql)。他們不再被維護[並被正式棄用](https://wiki.php.net/rfc/mysql_deprecation)。看到[**紅框**](http://j.mp/Te9zIL)?學習[*準備的語句*](http://j.mp/T9hLWi),並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [這篇文章](http://j.mp/QEx8IB)將幫助你決定哪個。如果你選擇PDO,[這裏是一個很好的教程](http://www.brightmeup.info/article.php?a_id=2)。 – 2013-03-18 09:54:18
爲sql注入好的洞好運 – 2013-03-18 09:54:51
爲什麼'結果;'後雖然lop – 2013-03-18 09:55:00