[英]php multidimensional array for html table
ok consider I have the following data from my database: 好的,考虑我的数据库中有以下数据:
string '20'
string '14'
float 6
string '15'
string '14'
float 10
20 & 15 are project ids 14 is the user id and the floats are hours 20和15是项目ID,14是用户ID,浮动时间是小时
I need to compile this data to be printed to a HTML table. 我需要编译此数据以将其打印到HTML表中。 The answer seems to be a multidimensional array.
答案似乎是多维数组。
so I assume this will look like this: 所以我认为这看起来像这样:
array (size 3)
0=> [project codes]
1=> [data (floats)]
2=> [user id's]
Is it possible to recursively search my returned mysql results for the project code and the user id and pop the float into the correct position in this case: 在这种情况下,是否可以递归地搜索我返回的mysql结果中的项目代码和用户ID,然后将浮点数弹出到正确的位置:
for project 20 and user id 14 insert 6 hours [20][6][14]. 对于项目20和用户ID 14,请插入6小时[20] [6] [14]。
load the array from the database "fetch loop" 从数据库“读取循环”中加载数组
$arr = array("project"=>$row['project_id'], "data"=>$row['data'], "userid"=>$row['user_id']);
display the data loop 显示数据循环
foreach ($arr as $valarr){
echo $valarr['data']; // your tds' line with the data
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.