I currently have an array that stores the values of one column from the database and that works fine however I want to store more than one column value. So in my example I want a team and their venue stored in the same array index. I can't seem find a way to do this.
If anyone can perhaps help that would be much appreciated.
Do you mean something like this?
$i = 0;
$my_array = array();
while ($row = mysql_fetch_assoc($result))
{
$my_array[$i]['name'] = $row['names'];
$my_array[$i]['otherfield'] = $row['otherfield'];
$i++;
}
now you can do something like this
echo $my_array[2]['name'];
Simply do :
$rows = [];
while($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.