Example picture in linked Above! (only to show the functionality I'm after) Functionality: What I'm looking for is a view on my website where a detail will (if there is sub-details) be rendered as a in HTML and then in the for that I'd like to present the sub-details (and if the sub-detail has sub-details, id like to do the same to that) Now I'd like to be able to do this up to 5-6 times (levels deep). As the example-picture shows (not my website), the material has sub-material. The sub-material also has sub-materials.
I'm currently only at level 2 (detail (level 1) -> sub-detail (level 2). How do I iterate this?
Below is my current code (only the part where the table goes).
<table class="tabell">
<tr>
<th scope="col" style="visibility: hidden;">ID</th>
<th scope="col">Articlenumber</th>
<th scope="col">Description</th>
<th scope="col">Weight Total(g)</th>
<th scope="col">Amount</th>
<th scope="col">Operations</th>
</tr>
<?php
$sqlproduct= "SELECT DISTINCT
mainarticle.mainArtNum,
mainarticle.mainName,
mainarticle.mainWeight,
componentarticle.compID,
componentarticle.compArtNum,
componentarticle.compName,
componentarticle.compWeight,
maincontains.mainContainsQuantity,
maincontains.mainContainsID
FROM
maincontains
INNER JOIN mainarticle ON maincontains.mainContainsMainID = mainarticle.mainID
INNER JOIN componentarticle ON maincontains.mainContainsCompID = componentarticle.compID
WHERE maincontains.maincontainsmainid ='$id';";
$result = mysqli_query($conn, $sqlproduct);
if($result){
while($row = mysqli_fetch_assoc($result)){
$sql2="SELECT * FROM compcontainsmaterial WHERE compID= $compID;";
$result2=mysqli_query($conn, $sql2);
if($result2){
$num = mysqli_num_rows($result2);
}
$sql3="SELECT * FROM files WHERE fileCompID= $compID;";
$result3=mysqli_query($conn, $sql3);
if($result3){
$num1 = mysqli_num_rows($result3);
}
$compID = $row['compID'];
$mainContainsID = $row['mainContainsID'];
$compArtNum = $row['compArtNum'];
$compName = $row['compName'];
$compWeight = $row['compWeight'];
$quantity = $row['mainContainsQuantity'];
$totWeight = ($compWeight * $quantity);
$sqlmaterialN2 = "SELECT * FROM materialContainsN2 WHERE";
$sqlN3N2 = "";
$sqlN4N3 = "";
echo '
<tr class="tabell-rad">
<td style="visibility: hidden;">'.$mainContainsID.'</td>
<td>'.$compArtNum.'</td>
<td>'.$compName.'</td>
<td>'.$totWeight.'</td>
<td>'.$quantity.'</td>
<td>
';
if($num1 > 0){
echo '<a title="Show documentation ('.$num1.')" href="./uploads.php?compID='.$compID.'&mainID='.$id.'"><img class="knapp" src="'.$documentation_icon.'"></a>';
}else{
echo '<a title="Add Documentation" href="./uploads.php?compID='.$compID.'&mainID='.$id.'"><img class="knapp" src="'.$documentation_add_icon.'"></a>';
}
if($num > 0){
echo '<a title="Show substances ('.$num.')" href="./listCompMaterial.php?compID='.$compID.'&mainID='.$id.'"><img class="knapp" src="'.$substances_icon.'"></a>';
}
else{
echo '<a title="Add substances" href="./linkMaterialToComp.php?compID='.$compID.'&mainID='.$id.'"><img class="knapp-gul" src="'.$substance_add_icon.'"></a>';
}echo '
<a title="Change weight" href="./updatecomp.php?compID='.$compID.'&mainID='.$id.'"><img class="knapp" src="'.$settings_icon.'"></a>
<a title="Delete" href="./deleteCompOnMain.php?mainContainsID='.$mainContainsID.'"><img class="knapp-r?�d" src="'.$delete_icon.'"></a>
</td>
</tr>';
}
//H?�r ?�r knappen som ska l?�nka till filuppladdning
//<button type="submit" class="knapp-tabell knapp"><a class="knapp-l?�nk" href="./uploads.php?compID='.$compID.'&mainID='.$id.'">Dokumentation</a></button>
} else {
echo "H?�r fanns det inget";
}
?>
</table>
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
DBMS is a database management system. It is designed to change, search, add and delete information in the database. There are many DBMSs designed for similar purposes with different features. One of the most popular is MySQL.
It is a software tool designed to work with relational SQL databases. It is easy to learn even for site owners who are not professional programmers or administrators. MySQL DBMS also allows you to export and import data, which is convenient when moving large amounts of information.
https://www.mysql.com/
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.