作者:灰包蛋啦_199 | 来源:互联网 | 2023-05-19 00:43
ImdoingawebappforparentsandIwanttocreatelielementsforeachchildrentheparentshave,
I'm doing a web app for parents and I want to create li elements for each children the parents have, to do so, I have a children database with all the children which use the software, I identify the parent's children by having a column which is filled with the parent email so to get the list of children I query all the children linked to that email.
我为父母做一个web应用程序,需要创建li元素为每个孩子的父母,要做到这一点,我有一个数据库的所有孩子使用软件,我确定父母的孩子通过一列这充满父邮件列表的孩子我查询所有的孩子都与电子邮件。
$stmt = $mysqli->prepare("SELECT id,nombre, medio, alergias, curso, grupo, plato FROM usuarios WHERE idmail = ? ORDER BY id ASC");
$stmt->bind_param('s', $_SESSION["email"]);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($id, $nombre, $medio, $alergias, $curso, $grupo, $plato);
$arrayfinal = array();
$stmt->store_result();
while($stmt->fetch()){
$arrayfinal[] = $id;
$arrayfinal[] = $nombre;
$arrayfinal[] = $medio;
$arrayfinal[] = $alergias;
$arrayfinal[] = $curso;
$arrayfinal[] = $grupo;
$arrayfinal[] = $plato;
}
The array "arrayfinal" includes all the family children information. The list looks like this:
数组“arrayfinal”包括所有家庭儿童信息。列表如下:
The back end looks like this:
后端是这样的:
That's for each element of the list.
这是列表的每个元素。
The array I mentioned before looks like this:
我之前提到的数组是这样的:
array(14) {
[0]=>
int(1)
[1]=>
string(5) "Ramon"
[2]=>
string(2) "12"
[3]=>
string(6) "Nueces"
[4]=>
string(5) "3 ESO"
[5]=>
string(1) "A"
[6]=>
string(1) "5"
[7]=>
int(2)
[8]=>
string(6) "Carlos"
[9]=>
string(2) "23"
[10]=>
string(7) "Lactosa"
[11]=>
string(6) "2 Batx"
[12]=>
string(1) "A"
[13]=>
string(1) "1"
}
In this array there's two kids "Carlos" and "Ramon".
在这个数组中有两个孩子“Carlos”和“Ramon”。
Summing up, what I want, is a list that automatically generates elements to the list for each kid the family has using PHP.
总结一下,我想要的是一个列表,它会自动为每个家庭使用PHP的孩子生成元素列表。
1 个解决方案