Php, вложенный цикл while, работает неправильно ⇐ Php
-
Anonymous
Php, вложенный цикл while, работает неправильно
I am attempting to get a nested loop to retrieve information from a database and arrange it by type. It retrieves the data but arranges it weird, kinda like this:
Crawler Dozer Excavator |Unit |Type |Year| Make | Model | Engine | --------------------------------------------------------------- |D8-1 |Crawler Dozer|0000| Caterpillar | D8K | D342 | So on and so forth..... It skips the title for the 'Crawler Dozer' and puts it under 'Excavator'. I have reworked the code several different ways, but still get the same result.
This is my code:
if(mysqli_query($conn, "select * from etypes") != null){ $etype_list=mysqli_query($conn, "select * from etypes order by name asc"); while($types_list=mysqli_fetch_array($etype_list)){ $cur_type = $types_list['name']; if(record_exists ("equipment", "type", "{$cur_type}")){ ?> Unit Type Year Make Model Engine Plate
Источник: https://stackoverflow.com/questions/781 ... -correctly
I am attempting to get a nested loop to retrieve information from a database and arrange it by type. It retrieves the data but arranges it weird, kinda like this:
Crawler Dozer Excavator |Unit |Type |Year| Make | Model | Engine | --------------------------------------------------------------- |D8-1 |Crawler Dozer|0000| Caterpillar | D8K | D342 | So on and so forth..... It skips the title for the 'Crawler Dozer' and puts it under 'Excavator'. I have reworked the code several different ways, but still get the same result.
This is my code:
if(mysqli_query($conn, "select * from etypes") != null){ $etype_list=mysqli_query($conn, "select * from etypes order by name asc"); while($types_list=mysqli_fetch_array($etype_list)){ $cur_type = $types_list['name']; if(record_exists ("equipment", "type", "{$cur_type}")){ ?> Unit Type Year Make Model Engine Plate
Источник: https://stackoverflow.com/questions/781 ... -correctly
Мобильная версия