从数据库而不是页内数组中选择多个数组 [英] Multiple Array Selection From Database Instead of In-Page Arrays

查看:45
本文介绍了从数据库而不是页内数组中选择多个数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




之前发布过,但这里会简化问题。如需原始帖子,请访问
http://forums.devshed.com /t80025/s.html


我在我的单页脚本中设置了2个这样的数组:


[PHP]

$ carers = array(

array(''names''=>''Carer 01'',''hours''=> 8,'''剩下''=> 8),

数组(''名字''=>''看护者02'',''小时''=> 12,''剩余''= > 12),

array(''names''=>''Carer 03'',''hours''=> 6,''remaining''=> 6) ,

);


$ clients = array(

array(''names''=>''Client 01 '',''hours''=> 2),

array(''names''=>''Client 02'',''hours''=> 3),

array(''names''=>''Client 03'',''hours''=> 4),

array(''names ''=>''客户04',''小时'=> 1),

数组(''names''=>''客户05'',''小时''=> 2),

数组(''names''=>''客户06'',''小时''=> 5),

);

[/ PHP]


但是,我想实际从MySQL表中检索这些数据。然后在页面下方进一步处理这些

数组。 DB看起来类似于

设置: http://www.monkey-it.co.uk/db_schema.gif


如你所见,我有一个名为''数据库'的数据库,两张桌子。现在,我将如何设置页面,以便从数据库中检索数据并使用它来进行页面下方的处理,就像上面的数组一样

原来。


非常感谢,


Janusz


-


************************************ ************** ***


QOTSA:Nicotine,Valium,Vicodin,Marijuana,Ecstacy and Alcohol

爱因斯坦:想象力比知识更重要

解决方案

carers = array(

array(' 'names''=>''Carer 01'',''hours''=> 8,''remaining''=> 8),

array(''names'' =>''Carer 02'',''hours''=> 12,''remaining''=> 12),

array(''names''=>' 'Carer 03'',''hours''=> 6,''剩余''=> 6),

);


clients = array(

array(''names''=>''Client 01'',''hours''=> 2),

array(''names''=>''Client 02'',''hours''=> 3),

array(' 'names''=>''Client 03'',''hours''=> 4),

array(''names''=>''Client 04'', ''hours''=> 1),

array(''names''=>''Client 05'',''hours''=> 2),
array(''names''=>''Client 06'',''hours''=> 5),

);

[/ PHP]


但是,我想实际从MySQL表中检索这些数据。然后在页面下方进一步处理这些

数组。 DB看起来类似于

设置: http://www.monkey-it.co.uk/db_schema.gif


如你所见,我有一个名为''数据库'的数据库,两张桌子。现在,我将如何设置页面,以便从数据库中检索数据并使用它来进行页面下方的处理,就像上面的数组一样

原来。


非常感谢,


Janusz


-


************************************ ************** ***


QOTSA:Nicotine,Valium,Vicodin,Marijuana,Ecstacy and Alcohol

爱因斯坦:想象力比知识更重要


2003年8月30日星期六11:27:31 + 0100,詹姆斯 < GR ****** @ dsl.pipex.com>写道:

但是,我想实际从MySQL表中检索这些数据。



http://uk.php.net/manual/en/function...etch- array.php


-

Andy Hassall(an**@andyh.co.uk)icq(5747695)( http://www.andyh.co.uk

Space :磁盘使用情况分析工具( http://www.andyhsoftware.co.uk/space


Hi,

Have posted before, but will simplify problem here. For original post go to
http://forums.devshed.com/t80025/s.html

I have setup 2 arrays like so in my one page script:

[PHP]
$carers = array(
array(''names'' => ''Carer 01'', ''hours'' => 8, ''remaining'' => 8),
array(''names'' => ''Carer 02'', ''hours'' => 12, ''remaining'' => 12),
array(''names'' => ''Carer 03'', ''hours'' => 6, ''remaining'' => 6),
);

$clients = array(
array(''names'' => ''Client 01'', ''hours'' => 2),
array(''names'' => ''Client 02'', ''hours'' => 3),
array(''names'' => ''Client 03'', ''hours'' => 4),
array(''names'' => ''Client 04'', ''hours'' => 1),
array(''names'' => ''Client 05'', ''hours'' => 2),
array(''names'' => ''Client 06'', ''hours'' => 5),
);
[/PHP]

However, I want to actually retrive this data from a MySQL table. These
arrays are then processed further down the page. The DB looks similar to the
setup here: http://www.monkey-it.co.uk/db_schema.gif

As you can see, I have a DB called ''database'' and two tables. Now, how would
I set the page up so that it would retrieve the data from the DB and use it
for processing further down the page like the above arrays would have
originally.

Many thanks,

Janusz

--

************************************************** ***

QOTSA: "Nicotine, Valium, Vicodin, Marijuana, Ecstacy and Alcohol"
Einstein: "Imagination is More Important Than Knowledge"

解决方案

carers = array(
array(''names'' => ''Carer 01'', ''hours'' => 8, ''remaining'' => 8),
array(''names'' => ''Carer 02'', ''hours'' => 12, ''remaining'' => 12),
array(''names'' => ''Carer 03'', ''hours'' => 6, ''remaining'' => 6),
);


clients = array(
array(''names'' => ''Client 01'', ''hours'' => 2),
array(''names'' => ''Client 02'', ''hours'' => 3),
array(''names'' => ''Client 03'', ''hours'' => 4),
array(''names'' => ''Client 04'', ''hours'' => 1),
array(''names'' => ''Client 05'', ''hours'' => 2),
array(''names'' => ''Client 06'', ''hours'' => 5),
);
[/PHP]

However, I want to actually retrive this data from a MySQL table. These
arrays are then processed further down the page. The DB looks similar to the
setup here: http://www.monkey-it.co.uk/db_schema.gif

As you can see, I have a DB called ''database'' and two tables. Now, how would
I set the page up so that it would retrieve the data from the DB and use it
for processing further down the page like the above arrays would have
originally.

Many thanks,

Janusz

--

************************************************** ***

QOTSA: "Nicotine, Valium, Vicodin, Marijuana, Ecstacy and Alcohol"
Einstein: "Imagination is More Important Than Knowledge"


On Sat, 30 Aug 2003 11:27:31 +0100, "James" <gr******@dsl.pipex.com> wrote:

However, I want to actually retrive this data from a MySQL table.



http://uk.php.net/manual/en/function...etch-array.php

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)


这篇关于从数据库而不是页内数组中选择多个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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