Hi I’m having a bit of trouble with this and wondering what to do. I want to create a php array from mysql results but only some of them out of the 4 will be valid results so for example ADULTMALE and MAST1MALE have values in the database for this particular row but MAST2MALE and SENMALE have no values for this particular query.
Here is my query which I know it works;
[php]$Admalecat = mysqli_query($con,“SELECT ADULTMALE, MAST1MALE, MAST2MALE, SENMALE FROM eventreg WHERE (ID=‘1’)ORDER BY ID DESC LIMIT 1”);[/php]
What I do after is I push them into an array but I only really want the results with the values (This is the bit I am sure I am doing wrong)
I am using a session as I need them later on another page. But anyway, ideally using the example above I would only want the 2 values that exist in the array.
[php]while($row = mysqli_fetch_array($Admalecat)) {
$_SESSION[adultmale] = array();
array_push($_SESSION[adultmale], $row[0]);
array_push($_SESSION[adultmale], $row[1]);
array_push($_SESSION[adultmale], $row[2]);
array_push($_SESSION[adultmale], $row[3]);
}[/php]
Any help muchly appreciated