I have problems with a three-level nested repeat region
because my DB is something complex...
levels : department > province > district
table department {id_dep, cod_dep, name_dep }
table province {id_prov, iddep_prov,cod_prov,name_prov }
table district {id_dis ,iddep_dis ,idprov_dis,cod_dis, name_dis }
Nesting among department > province is well
Nesting among province > district ... has errors
first intent:
see http://www.jsmoda.com/vencedor/nested1.php
second intent: (partial solution... )
see http://www.jsmoda.com/vencedor/nested2.php
For this second intent I added...
$vari = " AND iddep_dis =".$row_detail2ven_province_prov['iddep_prov'];
help me to solve this difficult problem
download la data and code
see http://www.jsmoda.com/vencedor/data.zip
thanks
ERIKA
three-level nested repeat region
Moderator: General Moderators
- nickman013
- Forum Regular
- Posts: 764
- Joined: Sun Aug 14, 2005 12:02 am
- Location: Long Island, New York
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
Untested...but should work...
please have indexes on all search fields...
I can use joins but it would be difficult to identify when new provinces and departments come...but if you think speed is a problem...you can use join to retrieve information and process it to form custom-formatted arrays which you can use later in the loops...
please have indexes on all search fields...
I can use joins but it would be difficult to identify when new provinces and departments come...but if you think speed is a problem...you can use join to retrieve information and process it to form custom-formatted arrays which you can use later in the loops...
Code: Select all
<style>
.district{
background-color:#DDFEFF;
}
.province{
background-color:#FFFEFF;
}
.department{
background-color:#FEEEFF;
}
</style>
<table>
<?php
$query = "select * from `department` order by `name_dep`";
if (is_resource($result = mysql_query($query))){
while($row = mysql_fetch_assoc($result)){
?>
<tr><td class = 'department'><?php echo $row["name_dep"]; ?></td></tr>
<?php
$query = "select * from `province` where `iddep_prov` =".$row["cod_dep"];
if (is_resource($result1 = mysql_query($query))){
while($row1 = mysql_fetch_assoc($result1)){
?>
<tr><td class = 'province'><?php echo $row1["name_prov"]; ?></td></tr>
<?php
$query = "select * from `district` where `idprov_dis` =".$row1["id_prov"];
if (is_resource($result2 = mysql_query($query))){
while($row2 = mysql_fetch_assoc($result2)){
?>
<tr><td class = 'district'><?php echo $row2["name_dis"]; ?></td></tr>
<?php
}
}
}
}
}
}
?>
</table>indices repeated randomly
hello!
When testing the code is obtained just like in case 1 http://www.jsmoda.com/vencedor/nested1.php
and this so that ?
it is so that the indices of the table ven_district_dis are not consecutive
1.2.4 4.5....(n-1)(n)
but is repeated randomly 1,2,3,4,---1,2.3---1,etc
to analyze
http://www.jsmoda.com/vencedor/data.zip
this is the great problem
helpme
thanks erika
When testing the code is obtained just like in case 1 http://www.jsmoda.com/vencedor/nested1.php
and this so that ?
it is so that the indices of the table ven_district_dis are not consecutive
1.2.4 4.5....(n-1)(n)
but is repeated randomly 1,2,3,4,---1,2.3---1,etc
to analyze
http://www.jsmoda.com/vencedor/data.zip
this is the great problem
helpme
thanks erika