I am running the below query. I can use the ticket_cost result column, but I'm having a hard time understanding how to pull the other data from the result.
$sql = "SELECT ticket_cost, GROUP_CONCAT(game ORDER BY game DESC SEPARATOR '|') FROM games WHERE id IN (" . implode(',', $myIDArray) . ") GROUP BY ticket_cost ORDER BY ticket_cost DESC";
$myresult = mysqli_query($connection,$sql);
Result looks something like this in phpmyadmin:
ticket_cost | GROUP_CONCAT(game ORDER BY game DESC SEPARATOR '|')
10 thisIsATest|thisIsATest2|thisIsATest3
5 thisIsAnotherTest
To display, I'm using:
echo "<ul>";
foreach($myresult as $row2)
{
echo "This doesn't work:" . $row2['game'];
echo "<li>" . $row2['ticket_cost'] . "</li>";
}
echo "</ul>";
This displays:
This doesn't work:
10
5
How can I display each of the pipe ("|") separated result items after each respective ticket_cost?
GROUP_CONCAT(game ORDER BY game DESC SEPARATOR '|') as gamesand then use$row['games']