这是我的代码:
$cast_name_list = explode(',',$result[$x]["cast_name"]);
$cast_profile_path = explode(',',$result[$x]["cast_profile_path"]);
$cast_character = explode(',',$result[$x]["cast_character"]);
foreach( $cast_name_list as $index => $cast_name )
{
echo 'name = '.$cast_name.'<br/> ';
echo ' character name = '.$cast_character[$index].' <br/>';
echo ' profile path = '.$cast_profile_path[$index].' <br/><br/><br/>';
}
这就是我在MySQL表中的数据如何:
cast_name cast_character cast_profile_path
Robert Iron man example.com/sdfsd.jpg
Rahul Mohit example.com/aadfsd.jpg
Tom Josh Null
Tripp James example.com/zzz.jpg
我想要的是:,如果表格中有NULL
个单元格,则整行不会回显。
即:Tom Josh Null
但是,这就是我的代码回应
name = robert
character name = Iron Man
profile path = example.com/sdfsd.jpg
name = Rahul
character name = Mohit
profile path = example.com/aadfsd.jpg
name = Tom
character name = Josh
profile path = example.com/zzz.jpg
name = Tripp
character name = James
profile path = Notice: Undefined offset: 8
预期输出:
name = robert
character name = Iron Man
profile path = example.com/sdfsd.jpg
name = Rahul
character name = Mohit
profile path = example.com/aadfsd.jpg
name = Tripp
character name = James
profile path = Notice: example.com/zzz.jpg
修改:由于第3行中的一个值为null
,因此$cast_profile_path
数组仅包含4个值,而$cast_name
&amp; $cast_character
包含5个值。
答案 0 :(得分:0)
试试这个:
var contentData = [
{
tops: [
{ image: "images/top1.jpg" },
{ image: "images/top2.jpg" },
{ image: "images/top3.jpg" },
{ image: "images/top4.jpg" } ]
}
];
$scope.objectArray = contentData;
$scope.objectCount = $scope.objectArray[0].length;
供参考,见:
注意不确定我是否理解正确,您是否在表格列中存储以逗号分隔的值?