我想显示表格中显示的这些点的列表。
folio_mainPoint_bulletPoint_table
idFolio idMainPoint idBulletPoint
8 13 14
8 13 15
8 14 16
8 15 17
8 15 18
8 15 19
这些是我的表格:
folioTable
idFolio folio
8 123
mainPointTable
idMainPoint mainPoint
13 Animals
13 Animals
14 Flowers
15 Insects
15 Insects
15 Insects
bulletPointTable
idBulletPoint bulletPoint
14 Dog
15 Cat
16 Rose
17 Ant
18 Grasshopper
19 Fly
20 ladybug
输出应为:
Folio 123
Animals
1. Dog
2. Cat
Flowers
1. Rose
Insects
1. Grasshopper
2. Fly
3. ladybug
我陷入困境,因为我一直在循环数据而不能打印出只有与idFolio为8的作品集相关的数据列表。这是我到目前为止的代码:
$sql = mysqli_query(" SELECT * FROM folio_mainPoint_bulletPoint_table where idFolio='8' ") or die(mysql_error());
while($row = mysqli_fetch_array( $sql )) {
echo $folio = $row['idFolio'];
$idBulletPoint = $row['idBulletPoint '];
$sql2 = mysql_query("SELECT bulletPoint FROM bulletPointTable where idBulletPoint ='$idBulletPoint' ");
while($row = mysqli_fetch_array( $sql2 )){
}
}
答案 0 :(得分:0)
试试此代码.. mysql_fetch_assoc()
$sql = mysql_query("SELECT * FROM folio_mainPoint_bulletPoint_table where idFolio='8'") or die(mysql_error());
while($row = mysql_fetch_assoc( $sql )) {
echo $folio = $row['idFolio'];
$idBulletPoint = $row['idBulletPoint '];
$sql2 = mysql_query("SELECT bulletPoint FROM bulletPointTable where idBulletPoint ='$idBulletPoint' ");
while($row1 = mysql_fetch_assoc( $sql2 )){
echo $row['column_name'];
}
}
答案 1 :(得分:0)
试试此代码
while($ result = mysql_fetch_assoc($ sql)){
的print_r($结果);
}