用于html表的php多维数组 [英] php multidimensional array for html table

查看:117
本文介绍了用于html表的php多维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定我的数据库中包含以下数据:

ok consider I have the following data from my database:

string '20' 
string '14' 
float 6

string '15'
string '14' 
float 10

20& 15是专案ID 用户ID为14 浮动时间是

20 & 15 are project ids 14 is the user id and the floats are hours

我需要编译此数据以将其打印到HTML表中.答案似乎是一个多维数组.

I need to compile this data to be printed to a HTML table. 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] 

在这种情况下,是否可以递归地搜索我返回的mysql结果中的项目代码和用户ID,然后将浮点数弹出到正确的位置:

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:

对于项目20和用户ID 14插入6小时[20] [6] [14].

for project 20 and user id 14 insert 6 hours [20][6][14].

推荐答案

从数据库获取循环"中加载数组

load the array from the database "fetch loop"

$arr = array("project"=>$row['project_id'], "data"=>$row['data'], "userid"=>$row['user_id']);

显示数据循环

foreach ($arr as $valarr){
   echo $valarr['data']; // your tds' line with the data
}

这篇关于用于html表的php多维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆