This is my code:
$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/>';
}
This is, how my data in MySQL table looks like:
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
What I want:, If there is a NULL
cell in the table, then the whole row will not echo.
i.e: Tom Josh Null
But, this is what my code echo
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
Expected Output:
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
Edit: Since one value is null
in 3rd row, so $cast_profile_path
array will contain only 4 values, while $cast_name
& $cast_character
contain 5 values.