Page 1 of 1

three-level nested repeat region

Posted: Sat Feb 04, 2006 3:13 pm
by erika_web
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

Posted: Sat Feb 04, 2006 4:36 pm
by nickman013
for the tables, why dont you just use <td align=center> instead of using &nbsp; to center the table data?

also this is in the wrong forum.

Posted: Sat Feb 04, 2006 6:37 pm
by feyd
Moved from General Discussion to Databases.

Posted: Sun Feb 05, 2006 8:53 am
by raghavan20
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...

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>

Posted: Sun Feb 05, 2006 2:04 pm
by erika_web
thanks friends....

I will review the code and I will respond as rapidly as possible

erika

indices repeated randomly

Posted: Tue Feb 07, 2006 9:14 am
by erika_web
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