数据表不工作

时间:2015-12-07 16:19:09

标签: javascript php datatable

您好我使用ssp clas作为数据表。

 function prod($a){
$query= mysql_query("SELECT name FROM products WHERE sipid = '$a'");
 while($row = mysql_fetch_array($query)){
     return $row[name];
 }
}

Ssp.class.php

 array(
    'db'        => 'id',
    'dt'        => 5,
    'formatter' => function( $d, $row ) {
       return prod($d);
    }
)

我在数据库中有两行,但这只显示一行?

1 个答案:

答案 0 :(得分:1)

返回

后不会执行任何语句

你回来了

while($row = mysql_fetch_array($query)){
   return $row[name];// this is wrong
}

将其更改为

$name = array();
while($row = mysql_fetch_array($query)){
   $name[] = $row[name];// assign to array
}
return $name;//   <--- return here.

同时切换为mysqli_*PDO,因为mysql_*已被弃用。