I have this php/html code that echos a column from a mysql table called "tickets". These are the 3 columns in the table (member_id, ticket_id, ticket_result).
I want to be able to grab the info from the other columns in a specific row and echo that with the foreach loop. I just don't know how I would be able to do that because you can only have 1 array in a foreach loop so if I was to make add this line to the PHP Code I don't see how I could echo it in the foreach loop.
$me3 = array();
$me2[] = $row->ticket_result;
PHP Code:
public function tickets() {
$this->db_connection = new mysqli('', '', '', '');
$sql = "SELECT ticket_result
FROM tickets
WHERE member_id = '1'";
$query = $this->db_connection->query($sql);
$me2 = array();
while ($row = $query->fetch_object()) {
$me2[] = $row->ticket_result;
}
return $me2;
}
}
HTML Code:
<?php $me2 = $classLogin->tickets(); ?>
<?php foreach($me2 as $value) { ?>
<table>
<thead>
<th>Result</th>
<th>ID</th>
</thead>
<tr>
<td><?php echo $value; ?> </td>
<td> </td>
<?php } ?>
</tr>
</table>
$me2[] = $row->ticket_id;etc. should do the trick. You may need to usefetch_assoc()though. Try that.$me2[] = array('member_id'=>$row->member_id, 'ticket_id'=>$row->ticket_id, 'ticket_result'=>$row->ticket_result);?