Dynamic Table with HTML and PHP












1















I show you my following problem .. I basically have the following database .. to understand it I think a practical example is the best way ..



I have a building site where N entrusters can intervene, these N trustees can in turn delegate N Sub-Affidiates.
then pulling the sums I have some relationships between the three tables (which in my language are "Cantiere" "Affidataria" "SubAffidataria")



Building site 1 ------> N Reliable



Relater 1 -----> N Sub-Affidiates



Having said that my problem is the following I have to do a control panel in which for each construction site I have to show the carers and the sub-contractors.
I would like to point out that the Sub-Affiliates do not have "direct" links with the Shipyards, but they have the FK of the Affilatories



It must be structured as follows ...



Under Each Relevant ("Affidataria") the results of the $ sql1 query must be placed
Under each Subsidiary ("SubAffidatari") the results of the $ sql2 query must be placed.



The question is how do I divide everything by columns?
I tried creating a dynamic HTML table .. but it does not work ..



I am attaching my proof ...



<!DOCTYPE html>
<?php
session_start();
if(!isset($_SESSION["username"])){
header('location: ../index.php');
}else
{

?>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_progettocantiere";


$idCantiere = $_GET["idCantiere"];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";
$result = $conn->query($sql);


if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {

echo'<h1 align="center">' . $row["codiceCommessa"] . '-' . $row["nomeCantiere"] . '</h1>';
}


} else {
echo "0 results";
}
$conn1 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn1->connect_error) {
die("Connection failed: " . $conn1->connect_error);
}

$sql1 = "SELECT idAffidataria,nomeCantiere FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
$result1 = $conn1->query($sql1);


//echo "<script type='text/javascript'>alert('$idAffidataria');</script>";

if ($result1->num_rows > 0)
{
// output data of each row
while($row1 = $result1->fetch_assoc())
{



echo'<br><br><br>';
echo '<h1> Affidataria</h1>';
echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
echo '<h1> SubAffidatario</h1>';
$idAffidataria = $row1["idAffidataria"];

$conn2 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn2->connect_error)
{
die("Connection failed: " . $conn2->connect_error);
}

$sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
$result2 = $conn2->query($sql2);
if ($result2->num_rows > 0)
{
// output data of each row
while($row2 = $result2->fetch_assoc())
{

// echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
echo'<br><br><br>';
echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row2["ragioneSocialeSubAffidatario"] . '">' . $row2["ragioneSocialeSubAffidatario"] . '</a>';
}
//echo'<br><br><br>';
//echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

}
else {
echo "0 results";
}

}
//echo'<br><br><br>';
//echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

}
else
{
echo "0 results";
}


$conn->close();

$conn1->close();


$conn2->close();


?>

<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Progetto Cantiere</title>
<!-- Bootstrap -->
<link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
</head>
<style>

.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #97c4fe;
-webkit-box-shadow:inset 0px 1px 0px 0px #97c4fe;
box-shadow:inset 0px 1px 0px 0px #97c4fe;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #3d94f6), color-stop(1, #1e62d0));
background:-moz-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-webkit-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-o-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-ms-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d94f6', endColorstr='#1e62d0',GradientType=0);
background-color:#3d94f6;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #0f73ff;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:28px;
font-weight:bold;
padding:32px 76px;
text-decoration:none;
text-shadow:0px 1px 0px #1570cd;
}
.myButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #1e62d0), color-stop(1, #3d94f6));
background:-moz-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-webkit-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-o-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-ms-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e62d0', endColorstr='#3d94f6',GradientType=0);
background-color:#1e62d0;
}
.myButton:active {
position:relative;
top:1px;
}

</style>

<body>


</body>
</html>
<?php } ?>


and this is the result I got:



enter image description here










share|improve this question

























  • you say you tried to create a html table... where is the <table> </table> block?

    – lovelace
    Nov 21 '18 at 20:39













  • I tried white '<table>' but it does not work ... I preferred to put this so it is clearer .. @lovelace

    – AlexLogic
    Nov 21 '18 at 20:45
















1















I show you my following problem .. I basically have the following database .. to understand it I think a practical example is the best way ..



I have a building site where N entrusters can intervene, these N trustees can in turn delegate N Sub-Affidiates.
then pulling the sums I have some relationships between the three tables (which in my language are "Cantiere" "Affidataria" "SubAffidataria")



Building site 1 ------> N Reliable



Relater 1 -----> N Sub-Affidiates



Having said that my problem is the following I have to do a control panel in which for each construction site I have to show the carers and the sub-contractors.
I would like to point out that the Sub-Affiliates do not have "direct" links with the Shipyards, but they have the FK of the Affilatories



It must be structured as follows ...



Under Each Relevant ("Affidataria") the results of the $ sql1 query must be placed
Under each Subsidiary ("SubAffidatari") the results of the $ sql2 query must be placed.



The question is how do I divide everything by columns?
I tried creating a dynamic HTML table .. but it does not work ..



I am attaching my proof ...



<!DOCTYPE html>
<?php
session_start();
if(!isset($_SESSION["username"])){
header('location: ../index.php');
}else
{

?>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_progettocantiere";


$idCantiere = $_GET["idCantiere"];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";
$result = $conn->query($sql);


if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {

echo'<h1 align="center">' . $row["codiceCommessa"] . '-' . $row["nomeCantiere"] . '</h1>';
}


} else {
echo "0 results";
}
$conn1 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn1->connect_error) {
die("Connection failed: " . $conn1->connect_error);
}

$sql1 = "SELECT idAffidataria,nomeCantiere FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
$result1 = $conn1->query($sql1);


//echo "<script type='text/javascript'>alert('$idAffidataria');</script>";

if ($result1->num_rows > 0)
{
// output data of each row
while($row1 = $result1->fetch_assoc())
{



echo'<br><br><br>';
echo '<h1> Affidataria</h1>';
echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
echo '<h1> SubAffidatario</h1>';
$idAffidataria = $row1["idAffidataria"];

$conn2 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn2->connect_error)
{
die("Connection failed: " . $conn2->connect_error);
}

$sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
$result2 = $conn2->query($sql2);
if ($result2->num_rows > 0)
{
// output data of each row
while($row2 = $result2->fetch_assoc())
{

// echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
echo'<br><br><br>';
echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row2["ragioneSocialeSubAffidatario"] . '">' . $row2["ragioneSocialeSubAffidatario"] . '</a>';
}
//echo'<br><br><br>';
//echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

}
else {
echo "0 results";
}

}
//echo'<br><br><br>';
//echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

}
else
{
echo "0 results";
}


$conn->close();

$conn1->close();


$conn2->close();


?>

<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Progetto Cantiere</title>
<!-- Bootstrap -->
<link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
</head>
<style>

.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #97c4fe;
-webkit-box-shadow:inset 0px 1px 0px 0px #97c4fe;
box-shadow:inset 0px 1px 0px 0px #97c4fe;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #3d94f6), color-stop(1, #1e62d0));
background:-moz-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-webkit-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-o-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-ms-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d94f6', endColorstr='#1e62d0',GradientType=0);
background-color:#3d94f6;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #0f73ff;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:28px;
font-weight:bold;
padding:32px 76px;
text-decoration:none;
text-shadow:0px 1px 0px #1570cd;
}
.myButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #1e62d0), color-stop(1, #3d94f6));
background:-moz-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-webkit-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-o-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-ms-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e62d0', endColorstr='#3d94f6',GradientType=0);
background-color:#1e62d0;
}
.myButton:active {
position:relative;
top:1px;
}

</style>

<body>


</body>
</html>
<?php } ?>


and this is the result I got:



enter image description here










share|improve this question

























  • you say you tried to create a html table... where is the <table> </table> block?

    – lovelace
    Nov 21 '18 at 20:39













  • I tried white '<table>' but it does not work ... I preferred to put this so it is clearer .. @lovelace

    – AlexLogic
    Nov 21 '18 at 20:45














1












1








1








I show you my following problem .. I basically have the following database .. to understand it I think a practical example is the best way ..



I have a building site where N entrusters can intervene, these N trustees can in turn delegate N Sub-Affidiates.
then pulling the sums I have some relationships between the three tables (which in my language are "Cantiere" "Affidataria" "SubAffidataria")



Building site 1 ------> N Reliable



Relater 1 -----> N Sub-Affidiates



Having said that my problem is the following I have to do a control panel in which for each construction site I have to show the carers and the sub-contractors.
I would like to point out that the Sub-Affiliates do not have "direct" links with the Shipyards, but they have the FK of the Affilatories



It must be structured as follows ...



Under Each Relevant ("Affidataria") the results of the $ sql1 query must be placed
Under each Subsidiary ("SubAffidatari") the results of the $ sql2 query must be placed.



The question is how do I divide everything by columns?
I tried creating a dynamic HTML table .. but it does not work ..



I am attaching my proof ...



<!DOCTYPE html>
<?php
session_start();
if(!isset($_SESSION["username"])){
header('location: ../index.php');
}else
{

?>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_progettocantiere";


$idCantiere = $_GET["idCantiere"];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";
$result = $conn->query($sql);


if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {

echo'<h1 align="center">' . $row["codiceCommessa"] . '-' . $row["nomeCantiere"] . '</h1>';
}


} else {
echo "0 results";
}
$conn1 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn1->connect_error) {
die("Connection failed: " . $conn1->connect_error);
}

$sql1 = "SELECT idAffidataria,nomeCantiere FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
$result1 = $conn1->query($sql1);


//echo "<script type='text/javascript'>alert('$idAffidataria');</script>";

if ($result1->num_rows > 0)
{
// output data of each row
while($row1 = $result1->fetch_assoc())
{



echo'<br><br><br>';
echo '<h1> Affidataria</h1>';
echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
echo '<h1> SubAffidatario</h1>';
$idAffidataria = $row1["idAffidataria"];

$conn2 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn2->connect_error)
{
die("Connection failed: " . $conn2->connect_error);
}

$sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
$result2 = $conn2->query($sql2);
if ($result2->num_rows > 0)
{
// output data of each row
while($row2 = $result2->fetch_assoc())
{

// echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
echo'<br><br><br>';
echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row2["ragioneSocialeSubAffidatario"] . '">' . $row2["ragioneSocialeSubAffidatario"] . '</a>';
}
//echo'<br><br><br>';
//echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

}
else {
echo "0 results";
}

}
//echo'<br><br><br>';
//echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

}
else
{
echo "0 results";
}


$conn->close();

$conn1->close();


$conn2->close();


?>

<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Progetto Cantiere</title>
<!-- Bootstrap -->
<link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
</head>
<style>

.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #97c4fe;
-webkit-box-shadow:inset 0px 1px 0px 0px #97c4fe;
box-shadow:inset 0px 1px 0px 0px #97c4fe;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #3d94f6), color-stop(1, #1e62d0));
background:-moz-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-webkit-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-o-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-ms-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d94f6', endColorstr='#1e62d0',GradientType=0);
background-color:#3d94f6;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #0f73ff;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:28px;
font-weight:bold;
padding:32px 76px;
text-decoration:none;
text-shadow:0px 1px 0px #1570cd;
}
.myButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #1e62d0), color-stop(1, #3d94f6));
background:-moz-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-webkit-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-o-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-ms-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e62d0', endColorstr='#3d94f6',GradientType=0);
background-color:#1e62d0;
}
.myButton:active {
position:relative;
top:1px;
}

</style>

<body>


</body>
</html>
<?php } ?>


and this is the result I got:



enter image description here










share|improve this question
















I show you my following problem .. I basically have the following database .. to understand it I think a practical example is the best way ..



I have a building site where N entrusters can intervene, these N trustees can in turn delegate N Sub-Affidiates.
then pulling the sums I have some relationships between the three tables (which in my language are "Cantiere" "Affidataria" "SubAffidataria")



Building site 1 ------> N Reliable



Relater 1 -----> N Sub-Affidiates



Having said that my problem is the following I have to do a control panel in which for each construction site I have to show the carers and the sub-contractors.
I would like to point out that the Sub-Affiliates do not have "direct" links with the Shipyards, but they have the FK of the Affilatories



It must be structured as follows ...



Under Each Relevant ("Affidataria") the results of the $ sql1 query must be placed
Under each Subsidiary ("SubAffidatari") the results of the $ sql2 query must be placed.



The question is how do I divide everything by columns?
I tried creating a dynamic HTML table .. but it does not work ..



I am attaching my proof ...



<!DOCTYPE html>
<?php
session_start();
if(!isset($_SESSION["username"])){
header('location: ../index.php');
}else
{

?>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_progettocantiere";


$idCantiere = $_GET["idCantiere"];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";
$result = $conn->query($sql);


if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {

echo'<h1 align="center">' . $row["codiceCommessa"] . '-' . $row["nomeCantiere"] . '</h1>';
}


} else {
echo "0 results";
}
$conn1 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn1->connect_error) {
die("Connection failed: " . $conn1->connect_error);
}

$sql1 = "SELECT idAffidataria,nomeCantiere FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
$result1 = $conn1->query($sql1);


//echo "<script type='text/javascript'>alert('$idAffidataria');</script>";

if ($result1->num_rows > 0)
{
// output data of each row
while($row1 = $result1->fetch_assoc())
{



echo'<br><br><br>';
echo '<h1> Affidataria</h1>';
echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
echo '<h1> SubAffidatario</h1>';
$idAffidataria = $row1["idAffidataria"];

$conn2 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn2->connect_error)
{
die("Connection failed: " . $conn2->connect_error);
}

$sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
$result2 = $conn2->query($sql2);
if ($result2->num_rows > 0)
{
// output data of each row
while($row2 = $result2->fetch_assoc())
{

// echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
echo'<br><br><br>';
echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row2["ragioneSocialeSubAffidatario"] . '">' . $row2["ragioneSocialeSubAffidatario"] . '</a>';
}
//echo'<br><br><br>';
//echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

}
else {
echo "0 results";
}

}
//echo'<br><br><br>';
//echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

}
else
{
echo "0 results";
}


$conn->close();

$conn1->close();


$conn2->close();


?>

<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Progetto Cantiere</title>
<!-- Bootstrap -->
<link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
</head>
<style>

.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #97c4fe;
-webkit-box-shadow:inset 0px 1px 0px 0px #97c4fe;
box-shadow:inset 0px 1px 0px 0px #97c4fe;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #3d94f6), color-stop(1, #1e62d0));
background:-moz-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-webkit-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-o-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-ms-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d94f6', endColorstr='#1e62d0',GradientType=0);
background-color:#3d94f6;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #0f73ff;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:28px;
font-weight:bold;
padding:32px 76px;
text-decoration:none;
text-shadow:0px 1px 0px #1570cd;
}
.myButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #1e62d0), color-stop(1, #3d94f6));
background:-moz-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-webkit-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-o-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-ms-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e62d0', endColorstr='#3d94f6',GradientType=0);
background-color:#1e62d0;
}
.myButton:active {
position:relative;
top:1px;
}

</style>

<body>


</body>
</html>
<?php } ?>


and this is the result I got:



enter image description here







javascript php mysqli html-table






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 22:17









Brian Tompsett - 汤莱恩

4,2231338101




4,2231338101










asked Nov 21 '18 at 20:26









AlexLogicAlexLogic

397




397













  • you say you tried to create a html table... where is the <table> </table> block?

    – lovelace
    Nov 21 '18 at 20:39













  • I tried white '<table>' but it does not work ... I preferred to put this so it is clearer .. @lovelace

    – AlexLogic
    Nov 21 '18 at 20:45



















  • you say you tried to create a html table... where is the <table> </table> block?

    – lovelace
    Nov 21 '18 at 20:39













  • I tried white '<table>' but it does not work ... I preferred to put this so it is clearer .. @lovelace

    – AlexLogic
    Nov 21 '18 at 20:45

















you say you tried to create a html table... where is the <table> </table> block?

– lovelace
Nov 21 '18 at 20:39







you say you tried to create a html table... where is the <table> </table> block?

– lovelace
Nov 21 '18 at 20:39















I tried white '<table>' but it does not work ... I preferred to put this so it is clearer .. @lovelace

– AlexLogic
Nov 21 '18 at 20:45





I tried white '<table>' but it does not work ... I preferred to put this so it is clearer .. @lovelace

– AlexLogic
Nov 21 '18 at 20:45












2 Answers
2






active

oldest

votes


















1














Try with the following code ..



<!DOCTYPE html>
<?php
session_start();
if(!isset($_SESSION["username"])){
header('location: ../index.php');
}else
{

?>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_progettocantiere";


$idCantiere = $_GET["idCantiere"];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";
$result = $conn->query($sql);


if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {

echo'<h1 align="center">' . $row["codiceCommessa"] . '-' . $row["nomeCantiere"] . '</h1>';
}


} else {
echo "0 results";
}
$conn1 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn1->connect_error) {
die("Connection failed: " . $conn1->connect_error);
}

$sql1 = "SELECT * FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
$result1 = $conn1->query($sql1);


//echo "<script type='text/javascript'>alert('$idAffidataria');</script>";

if ($result1->num_rows > 0)
{
// output data of each row
while($row1 = $result1->fetch_assoc())
{



echo '<table align="center" border="3px" width = "900px">';

echo '<tr>';
echo '<td><h1>Anagrafica</h1>';
echo '<td><h1> Affidataria</h1></td>';
echo '<td><h1> SubAffidatario</h1></td></tr>';
echo '<tr><td><a class="myButton" href="../../pagineHtml/modifica/modifica/inserimentoCantiere.php?idCantiere=' . $row1["fkIDCantiere"] . '">Anagrafica</a></td>';
echo '<td><a class="myButton" href="../../pagineHtml/modifica/modifica/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a></td></tr>';

$idAffidataria = $row1["idAffidataria"];

$conn2 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn2->connect_error)
{
die("Connection failed: " . $conn2->connect_error);
}

$sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
$result2 = $conn2->query($sql2);
if ($result2->num_rows > 0)
{
// output data of each row
while($row2 = $result2->fetch_assoc())
{

// echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
echo'<br><br><br>';
echo '<tr>';
echo '<td></td>';
echo '<td></td>';
echo '<td><a class="myButton" href="../../pagineHtml/modifica/modifica/subAffidatario.php?idSubAffidatario=' . $row2["idSubAffidatario"] . '">' . $row2["ragioneSocialeSubAffidatario"] . '</a></td>';
}
//echo'<br><br><br>';
//echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

}
else {
echo "0 results";
}

}
//echo'<br><br><br>';
//echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

}
else
{
echo "0 results";
}
echo'</tr>';
echo '</table>';

$conn->close();

$conn1->close();


$conn2->close();


?>

<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Progetto Cantiere</title>
<!-- Bootstrap -->
<link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
</head>
<style>

.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #97c4fe;
-webkit-box-shadow:inset 0px 1px 0px 0px #97c4fe;
box-shadow:inset 0px 1px 0px 0px #97c4fe;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #3d94f6), color-stop(1, #1e62d0));
background:-moz-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-webkit-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-o-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:-ms-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
background:linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d94f6', endColorstr='#1e62d0',GradientType=0);
background-color:#3d94f6;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #0f73ff;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:28px;
font-weight:bold;
padding:32px 76px;
text-decoration:none;
text-shadow:0px 1px 0px #1570cd;
}
.myButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #1e62d0), color-stop(1, #3d94f6));
background:-moz-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-webkit-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-o-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:-ms-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
background:linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e62d0', endColorstr='#3d94f6',GradientType=0);
background-color:#1e62d0;
}
.myButton:active {
position:relative;
top:1px;
}

</style>

<body>


</body>
</html>
<?php } ?>





share|improve this answer

































    0














    Try this, but I'm not sure if it's what you asked for, because I did not understand what you wanted.



        <?php 

    session_start();

    if(!isset($_SESSION["username"])){
    header('location: ../index.php');
    }



    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "my_progettocantiere";



    $idCantiere = $_GET["idCantiere"];

    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);

    // Check connection
    if ($conn->connect_error)
    {
    die("Connection failed: " . $conn->connect_error);
    }

    ?>

    <!DOCTYPE html>

    <html lang="en">

    <head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Progetto Cantiere</title>
    <!-- Bootstrap -->
    <link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">


    </head>

    <body>

    <div class="container">

    <div class="row">

    <?php

    $sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";

    $result = $conn->query($sql);


    if ($result->num_rows > 0) {

    while($row = $result->fetch_assoc())
    {

    ?>
    <div class="col-sm-12">
    <h1> <?php echo $row["codiceCommessa"] . '-' . $row["nomeCantiere"] ?></h1>
    </div>
    <?php
    }

    } else {

    echo "0 results";

    }

    ?>
    </div>

    <?php
    $sql1 = "SELECT idAffidataria,nomeCantiere FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
    $result1 = $conn->query($sql1);


    if ($result1->num_rows > 0)
    {
    // output data of each row
    while($row1 = $result1->fetch_assoc())
    {

    ?>
    <div class="row">

    <div class="col-sm-11 offset-sm-1">

    <h1>Affidataria</h1>
    <a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria= <?php echo $row1["idAffidataria"] ?>">
    <?php echo $row1["nomeCantiere"] ?>
    </a>

    </div>


    <div class="col-sm-6 offset-sm-2">
    <h1>SubAffidatario</h1>

    <?php

    $idAffidataria = $row1["idAffidataria"];

    $sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
    $result2 = $conn->query($sql2);

    if ($result2->num_rows > 0)
    {
    // output data of each row
    while($row2 = $result2->fetch_assoc())
    {
    ?>
    <div class="col-sm-10">
    <br>
    <a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=<?php echo $row2["ragioneSocialeSubAffidatario"] ?>">
    <?php echo $row2["ragioneSocialeSubAffidatario"] ?>

    </a>
    </div>
    <?php
    }

    }else {
    echo "0 results";
    }

    }

    ?>
    </div>
    <?php

    }else{

    echo "0 results";

    }

    $conn->close();

    ?>

    </div>
    </div>

    </body>

    </html>





    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419986%2fdynamic-table-with-html-and-php%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Try with the following code ..



      <!DOCTYPE html>
      <?php
      session_start();
      if(!isset($_SESSION["username"])){
      header('location: ../index.php');
      }else
      {

      ?>
      <?php
      $servername = "localhost";
      $username = "root";
      $password = "";
      $dbname = "my_progettocantiere";


      $idCantiere = $_GET["idCantiere"];
      // Create connection
      $conn = new mysqli($servername, $username, $password, $dbname);
      // Check connection
      if ($conn->connect_error) {
      die("Connection failed: " . $conn->connect_error);
      }
      $sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";
      $result = $conn->query($sql);


      if ($result->num_rows > 0) {
      // output data of each row
      while($row = $result->fetch_assoc()) {

      echo'<h1 align="center">' . $row["codiceCommessa"] . '-' . $row["nomeCantiere"] . '</h1>';
      }


      } else {
      echo "0 results";
      }
      $conn1 = new mysqli($servername, $username, $password, $dbname);
      // Check connection
      if ($conn1->connect_error) {
      die("Connection failed: " . $conn1->connect_error);
      }

      $sql1 = "SELECT * FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
      $result1 = $conn1->query($sql1);


      //echo "<script type='text/javascript'>alert('$idAffidataria');</script>";

      if ($result1->num_rows > 0)
      {
      // output data of each row
      while($row1 = $result1->fetch_assoc())
      {



      echo '<table align="center" border="3px" width = "900px">';

      echo '<tr>';
      echo '<td><h1>Anagrafica</h1>';
      echo '<td><h1> Affidataria</h1></td>';
      echo '<td><h1> SubAffidatario</h1></td></tr>';
      echo '<tr><td><a class="myButton" href="../../pagineHtml/modifica/modifica/inserimentoCantiere.php?idCantiere=' . $row1["fkIDCantiere"] . '">Anagrafica</a></td>';
      echo '<td><a class="myButton" href="../../pagineHtml/modifica/modifica/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a></td></tr>';

      $idAffidataria = $row1["idAffidataria"];

      $conn2 = new mysqli($servername, $username, $password, $dbname);
      // Check connection
      if ($conn2->connect_error)
      {
      die("Connection failed: " . $conn2->connect_error);
      }

      $sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
      $result2 = $conn2->query($sql2);
      if ($result2->num_rows > 0)
      {
      // output data of each row
      while($row2 = $result2->fetch_assoc())
      {

      // echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
      echo'<br><br><br>';
      echo '<tr>';
      echo '<td></td>';
      echo '<td></td>';
      echo '<td><a class="myButton" href="../../pagineHtml/modifica/modifica/subAffidatario.php?idSubAffidatario=' . $row2["idSubAffidatario"] . '">' . $row2["ragioneSocialeSubAffidatario"] . '</a></td>';
      }
      //echo'<br><br><br>';
      //echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

      }
      else {
      echo "0 results";
      }

      }
      //echo'<br><br><br>';
      //echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

      }
      else
      {
      echo "0 results";
      }
      echo'</tr>';
      echo '</table>';

      $conn->close();

      $conn1->close();


      $conn2->close();


      ?>

      <html lang="en">
      <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>Progetto Cantiere</title>
      <!-- Bootstrap -->
      <link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
      </head>
      <style>

      .myButton {
      -moz-box-shadow:inset 0px 1px 0px 0px #97c4fe;
      -webkit-box-shadow:inset 0px 1px 0px 0px #97c4fe;
      box-shadow:inset 0px 1px 0px 0px #97c4fe;
      background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #3d94f6), color-stop(1, #1e62d0));
      background:-moz-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
      background:-webkit-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
      background:-o-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
      background:-ms-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
      background:linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
      filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d94f6', endColorstr='#1e62d0',GradientType=0);
      background-color:#3d94f6;
      -moz-border-radius:6px;
      -webkit-border-radius:6px;
      border-radius:6px;
      border:1px solid #0f73ff;
      display:inline-block;
      cursor:pointer;
      color:#ffffff;
      font-family:Arial;
      font-size:28px;
      font-weight:bold;
      padding:32px 76px;
      text-decoration:none;
      text-shadow:0px 1px 0px #1570cd;
      }
      .myButton:hover {
      background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #1e62d0), color-stop(1, #3d94f6));
      background:-moz-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
      background:-webkit-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
      background:-o-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
      background:-ms-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
      background:linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
      filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e62d0', endColorstr='#3d94f6',GradientType=0);
      background-color:#1e62d0;
      }
      .myButton:active {
      position:relative;
      top:1px;
      }

      </style>

      <body>


      </body>
      </html>
      <?php } ?>





      share|improve this answer






























        1














        Try with the following code ..



        <!DOCTYPE html>
        <?php
        session_start();
        if(!isset($_SESSION["username"])){
        header('location: ../index.php');
        }else
        {

        ?>
        <?php
        $servername = "localhost";
        $username = "root";
        $password = "";
        $dbname = "my_progettocantiere";


        $idCantiere = $_GET["idCantiere"];
        // Create connection
        $conn = new mysqli($servername, $username, $password, $dbname);
        // Check connection
        if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
        }
        $sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";
        $result = $conn->query($sql);


        if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {

        echo'<h1 align="center">' . $row["codiceCommessa"] . '-' . $row["nomeCantiere"] . '</h1>';
        }


        } else {
        echo "0 results";
        }
        $conn1 = new mysqli($servername, $username, $password, $dbname);
        // Check connection
        if ($conn1->connect_error) {
        die("Connection failed: " . $conn1->connect_error);
        }

        $sql1 = "SELECT * FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
        $result1 = $conn1->query($sql1);


        //echo "<script type='text/javascript'>alert('$idAffidataria');</script>";

        if ($result1->num_rows > 0)
        {
        // output data of each row
        while($row1 = $result1->fetch_assoc())
        {



        echo '<table align="center" border="3px" width = "900px">';

        echo '<tr>';
        echo '<td><h1>Anagrafica</h1>';
        echo '<td><h1> Affidataria</h1></td>';
        echo '<td><h1> SubAffidatario</h1></td></tr>';
        echo '<tr><td><a class="myButton" href="../../pagineHtml/modifica/modifica/inserimentoCantiere.php?idCantiere=' . $row1["fkIDCantiere"] . '">Anagrafica</a></td>';
        echo '<td><a class="myButton" href="../../pagineHtml/modifica/modifica/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a></td></tr>';

        $idAffidataria = $row1["idAffidataria"];

        $conn2 = new mysqli($servername, $username, $password, $dbname);
        // Check connection
        if ($conn2->connect_error)
        {
        die("Connection failed: " . $conn2->connect_error);
        }

        $sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
        $result2 = $conn2->query($sql2);
        if ($result2->num_rows > 0)
        {
        // output data of each row
        while($row2 = $result2->fetch_assoc())
        {

        // echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
        echo'<br><br><br>';
        echo '<tr>';
        echo '<td></td>';
        echo '<td></td>';
        echo '<td><a class="myButton" href="../../pagineHtml/modifica/modifica/subAffidatario.php?idSubAffidatario=' . $row2["idSubAffidatario"] . '">' . $row2["ragioneSocialeSubAffidatario"] . '</a></td>';
        }
        //echo'<br><br><br>';
        //echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

        }
        else {
        echo "0 results";
        }

        }
        //echo'<br><br><br>';
        //echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

        }
        else
        {
        echo "0 results";
        }
        echo'</tr>';
        echo '</table>';

        $conn->close();

        $conn1->close();


        $conn2->close();


        ?>

        <html lang="en">
        <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Progetto Cantiere</title>
        <!-- Bootstrap -->
        <link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
        </head>
        <style>

        .myButton {
        -moz-box-shadow:inset 0px 1px 0px 0px #97c4fe;
        -webkit-box-shadow:inset 0px 1px 0px 0px #97c4fe;
        box-shadow:inset 0px 1px 0px 0px #97c4fe;
        background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #3d94f6), color-stop(1, #1e62d0));
        background:-moz-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
        background:-webkit-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
        background:-o-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
        background:-ms-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
        background:linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d94f6', endColorstr='#1e62d0',GradientType=0);
        background-color:#3d94f6;
        -moz-border-radius:6px;
        -webkit-border-radius:6px;
        border-radius:6px;
        border:1px solid #0f73ff;
        display:inline-block;
        cursor:pointer;
        color:#ffffff;
        font-family:Arial;
        font-size:28px;
        font-weight:bold;
        padding:32px 76px;
        text-decoration:none;
        text-shadow:0px 1px 0px #1570cd;
        }
        .myButton:hover {
        background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #1e62d0), color-stop(1, #3d94f6));
        background:-moz-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
        background:-webkit-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
        background:-o-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
        background:-ms-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
        background:linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e62d0', endColorstr='#3d94f6',GradientType=0);
        background-color:#1e62d0;
        }
        .myButton:active {
        position:relative;
        top:1px;
        }

        </style>

        <body>


        </body>
        </html>
        <?php } ?>





        share|improve this answer




























          1












          1








          1







          Try with the following code ..



          <!DOCTYPE html>
          <?php
          session_start();
          if(!isset($_SESSION["username"])){
          header('location: ../index.php');
          }else
          {

          ?>
          <?php
          $servername = "localhost";
          $username = "root";
          $password = "";
          $dbname = "my_progettocantiere";


          $idCantiere = $_GET["idCantiere"];
          // Create connection
          $conn = new mysqli($servername, $username, $password, $dbname);
          // Check connection
          if ($conn->connect_error) {
          die("Connection failed: " . $conn->connect_error);
          }
          $sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";
          $result = $conn->query($sql);


          if ($result->num_rows > 0) {
          // output data of each row
          while($row = $result->fetch_assoc()) {

          echo'<h1 align="center">' . $row["codiceCommessa"] . '-' . $row["nomeCantiere"] . '</h1>';
          }


          } else {
          echo "0 results";
          }
          $conn1 = new mysqli($servername, $username, $password, $dbname);
          // Check connection
          if ($conn1->connect_error) {
          die("Connection failed: " . $conn1->connect_error);
          }

          $sql1 = "SELECT * FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
          $result1 = $conn1->query($sql1);


          //echo "<script type='text/javascript'>alert('$idAffidataria');</script>";

          if ($result1->num_rows > 0)
          {
          // output data of each row
          while($row1 = $result1->fetch_assoc())
          {



          echo '<table align="center" border="3px" width = "900px">';

          echo '<tr>';
          echo '<td><h1>Anagrafica</h1>';
          echo '<td><h1> Affidataria</h1></td>';
          echo '<td><h1> SubAffidatario</h1></td></tr>';
          echo '<tr><td><a class="myButton" href="../../pagineHtml/modifica/modifica/inserimentoCantiere.php?idCantiere=' . $row1["fkIDCantiere"] . '">Anagrafica</a></td>';
          echo '<td><a class="myButton" href="../../pagineHtml/modifica/modifica/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a></td></tr>';

          $idAffidataria = $row1["idAffidataria"];

          $conn2 = new mysqli($servername, $username, $password, $dbname);
          // Check connection
          if ($conn2->connect_error)
          {
          die("Connection failed: " . $conn2->connect_error);
          }

          $sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
          $result2 = $conn2->query($sql2);
          if ($result2->num_rows > 0)
          {
          // output data of each row
          while($row2 = $result2->fetch_assoc())
          {

          // echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
          echo'<br><br><br>';
          echo '<tr>';
          echo '<td></td>';
          echo '<td></td>';
          echo '<td><a class="myButton" href="../../pagineHtml/modifica/modifica/subAffidatario.php?idSubAffidatario=' . $row2["idSubAffidatario"] . '">' . $row2["ragioneSocialeSubAffidatario"] . '</a></td>';
          }
          //echo'<br><br><br>';
          //echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

          }
          else {
          echo "0 results";
          }

          }
          //echo'<br><br><br>';
          //echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

          }
          else
          {
          echo "0 results";
          }
          echo'</tr>';
          echo '</table>';

          $conn->close();

          $conn1->close();


          $conn2->close();


          ?>

          <html lang="en">
          <head>
          <meta charset="utf-8">
          <meta http-equiv="X-UA-Compatible" content="IE=edge">
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <title>Progetto Cantiere</title>
          <!-- Bootstrap -->
          <link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
          </head>
          <style>

          .myButton {
          -moz-box-shadow:inset 0px 1px 0px 0px #97c4fe;
          -webkit-box-shadow:inset 0px 1px 0px 0px #97c4fe;
          box-shadow:inset 0px 1px 0px 0px #97c4fe;
          background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #3d94f6), color-stop(1, #1e62d0));
          background:-moz-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
          background:-webkit-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
          background:-o-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
          background:-ms-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
          background:linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
          filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d94f6', endColorstr='#1e62d0',GradientType=0);
          background-color:#3d94f6;
          -moz-border-radius:6px;
          -webkit-border-radius:6px;
          border-radius:6px;
          border:1px solid #0f73ff;
          display:inline-block;
          cursor:pointer;
          color:#ffffff;
          font-family:Arial;
          font-size:28px;
          font-weight:bold;
          padding:32px 76px;
          text-decoration:none;
          text-shadow:0px 1px 0px #1570cd;
          }
          .myButton:hover {
          background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #1e62d0), color-stop(1, #3d94f6));
          background:-moz-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
          background:-webkit-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
          background:-o-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
          background:-ms-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
          background:linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
          filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e62d0', endColorstr='#3d94f6',GradientType=0);
          background-color:#1e62d0;
          }
          .myButton:active {
          position:relative;
          top:1px;
          }

          </style>

          <body>


          </body>
          </html>
          <?php } ?>





          share|improve this answer















          Try with the following code ..



          <!DOCTYPE html>
          <?php
          session_start();
          if(!isset($_SESSION["username"])){
          header('location: ../index.php');
          }else
          {

          ?>
          <?php
          $servername = "localhost";
          $username = "root";
          $password = "";
          $dbname = "my_progettocantiere";


          $idCantiere = $_GET["idCantiere"];
          // Create connection
          $conn = new mysqli($servername, $username, $password, $dbname);
          // Check connection
          if ($conn->connect_error) {
          die("Connection failed: " . $conn->connect_error);
          }
          $sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";
          $result = $conn->query($sql);


          if ($result->num_rows > 0) {
          // output data of each row
          while($row = $result->fetch_assoc()) {

          echo'<h1 align="center">' . $row["codiceCommessa"] . '-' . $row["nomeCantiere"] . '</h1>';
          }


          } else {
          echo "0 results";
          }
          $conn1 = new mysqli($servername, $username, $password, $dbname);
          // Check connection
          if ($conn1->connect_error) {
          die("Connection failed: " . $conn1->connect_error);
          }

          $sql1 = "SELECT * FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
          $result1 = $conn1->query($sql1);


          //echo "<script type='text/javascript'>alert('$idAffidataria');</script>";

          if ($result1->num_rows > 0)
          {
          // output data of each row
          while($row1 = $result1->fetch_assoc())
          {



          echo '<table align="center" border="3px" width = "900px">';

          echo '<tr>';
          echo '<td><h1>Anagrafica</h1>';
          echo '<td><h1> Affidataria</h1></td>';
          echo '<td><h1> SubAffidatario</h1></td></tr>';
          echo '<tr><td><a class="myButton" href="../../pagineHtml/modifica/modifica/inserimentoCantiere.php?idCantiere=' . $row1["fkIDCantiere"] . '">Anagrafica</a></td>';
          echo '<td><a class="myButton" href="../../pagineHtml/modifica/modifica/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a></td></tr>';

          $idAffidataria = $row1["idAffidataria"];

          $conn2 = new mysqli($servername, $username, $password, $dbname);
          // Check connection
          if ($conn2->connect_error)
          {
          die("Connection failed: " . $conn2->connect_error);
          }

          $sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
          $result2 = $conn2->query($sql2);
          if ($result2->num_rows > 0)
          {
          // output data of each row
          while($row2 = $result2->fetch_assoc())
          {

          // echo '<a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=' . $row1["idAffidataria"] . '">' . $row1["nomeCantiere"] . '</a>';
          echo'<br><br><br>';
          echo '<tr>';
          echo '<td></td>';
          echo '<td></td>';
          echo '<td><a class="myButton" href="../../pagineHtml/modifica/modifica/subAffidatario.php?idSubAffidatario=' . $row2["idSubAffidatario"] . '">' . $row2["ragioneSocialeSubAffidatario"] . '</a></td>';
          }
          //echo'<br><br><br>';
          //echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

          }
          else {
          echo "0 results";
          }

          }
          //echo'<br><br><br>';
          //echo '<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="myButton" alt="Nuovo Cantiere +">Nuovo Cantiere +</a>';

          }
          else
          {
          echo "0 results";
          }
          echo'</tr>';
          echo '</table>';

          $conn->close();

          $conn1->close();


          $conn2->close();


          ?>

          <html lang="en">
          <head>
          <meta charset="utf-8">
          <meta http-equiv="X-UA-Compatible" content="IE=edge">
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <title>Progetto Cantiere</title>
          <!-- Bootstrap -->
          <link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
          </head>
          <style>

          .myButton {
          -moz-box-shadow:inset 0px 1px 0px 0px #97c4fe;
          -webkit-box-shadow:inset 0px 1px 0px 0px #97c4fe;
          box-shadow:inset 0px 1px 0px 0px #97c4fe;
          background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #3d94f6), color-stop(1, #1e62d0));
          background:-moz-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
          background:-webkit-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
          background:-o-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
          background:-ms-linear-gradient(top, #3d94f6 5%, #1e62d0 100%);
          background:linear-gradient(to bottom, #3d94f6 5%, #1e62d0 100%);
          filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#3d94f6', endColorstr='#1e62d0',GradientType=0);
          background-color:#3d94f6;
          -moz-border-radius:6px;
          -webkit-border-radius:6px;
          border-radius:6px;
          border:1px solid #0f73ff;
          display:inline-block;
          cursor:pointer;
          color:#ffffff;
          font-family:Arial;
          font-size:28px;
          font-weight:bold;
          padding:32px 76px;
          text-decoration:none;
          text-shadow:0px 1px 0px #1570cd;
          }
          .myButton:hover {
          background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #1e62d0), color-stop(1, #3d94f6));
          background:-moz-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
          background:-webkit-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
          background:-o-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
          background:-ms-linear-gradient(top, #1e62d0 5%, #3d94f6 100%);
          background:linear-gradient(to bottom, #1e62d0 5%, #3d94f6 100%);
          filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1e62d0', endColorstr='#3d94f6',GradientType=0);
          background-color:#1e62d0;
          }
          .myButton:active {
          position:relative;
          top:1px;
          }

          </style>

          <body>


          </body>
          </html>
          <?php } ?>






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 21 '18 at 22:30









          Pedro Lobito

          49k14136165




          49k14136165










          answered Nov 21 '18 at 21:59









          NarcosZTK_10NarcosZTK_10

          928




          928

























              0














              Try this, but I'm not sure if it's what you asked for, because I did not understand what you wanted.



                  <?php 

              session_start();

              if(!isset($_SESSION["username"])){
              header('location: ../index.php');
              }



              $servername = "localhost";
              $username = "root";
              $password = "";
              $dbname = "my_progettocantiere";



              $idCantiere = $_GET["idCantiere"];

              // Create connection
              $conn = new mysqli($servername, $username, $password, $dbname);

              // Check connection
              if ($conn->connect_error)
              {
              die("Connection failed: " . $conn->connect_error);
              }

              ?>

              <!DOCTYPE html>

              <html lang="en">

              <head>

              <meta charset="utf-8">
              <meta http-equiv="X-UA-Compatible" content="IE=edge">
              <meta name="viewport" content="width=device-width, initial-scale=1">
              <title>Progetto Cantiere</title>
              <!-- Bootstrap -->
              <link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
              <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">


              </head>

              <body>

              <div class="container">

              <div class="row">

              <?php

              $sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";

              $result = $conn->query($sql);


              if ($result->num_rows > 0) {

              while($row = $result->fetch_assoc())
              {

              ?>
              <div class="col-sm-12">
              <h1> <?php echo $row["codiceCommessa"] . '-' . $row["nomeCantiere"] ?></h1>
              </div>
              <?php
              }

              } else {

              echo "0 results";

              }

              ?>
              </div>

              <?php
              $sql1 = "SELECT idAffidataria,nomeCantiere FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
              $result1 = $conn->query($sql1);


              if ($result1->num_rows > 0)
              {
              // output data of each row
              while($row1 = $result1->fetch_assoc())
              {

              ?>
              <div class="row">

              <div class="col-sm-11 offset-sm-1">

              <h1>Affidataria</h1>
              <a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria= <?php echo $row1["idAffidataria"] ?>">
              <?php echo $row1["nomeCantiere"] ?>
              </a>

              </div>


              <div class="col-sm-6 offset-sm-2">
              <h1>SubAffidatario</h1>

              <?php

              $idAffidataria = $row1["idAffidataria"];

              $sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
              $result2 = $conn->query($sql2);

              if ($result2->num_rows > 0)
              {
              // output data of each row
              while($row2 = $result2->fetch_assoc())
              {
              ?>
              <div class="col-sm-10">
              <br>
              <a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=<?php echo $row2["ragioneSocialeSubAffidatario"] ?>">
              <?php echo $row2["ragioneSocialeSubAffidatario"] ?>

              </a>
              </div>
              <?php
              }

              }else {
              echo "0 results";
              }

              }

              ?>
              </div>
              <?php

              }else{

              echo "0 results";

              }

              $conn->close();

              ?>

              </div>
              </div>

              </body>

              </html>





              share|improve this answer






























                0














                Try this, but I'm not sure if it's what you asked for, because I did not understand what you wanted.



                    <?php 

                session_start();

                if(!isset($_SESSION["username"])){
                header('location: ../index.php');
                }



                $servername = "localhost";
                $username = "root";
                $password = "";
                $dbname = "my_progettocantiere";



                $idCantiere = $_GET["idCantiere"];

                // Create connection
                $conn = new mysqli($servername, $username, $password, $dbname);

                // Check connection
                if ($conn->connect_error)
                {
                die("Connection failed: " . $conn->connect_error);
                }

                ?>

                <!DOCTYPE html>

                <html lang="en">

                <head>

                <meta charset="utf-8">
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
                <meta name="viewport" content="width=device-width, initial-scale=1">
                <title>Progetto Cantiere</title>
                <!-- Bootstrap -->
                <link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
                <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">


                </head>

                <body>

                <div class="container">

                <div class="row">

                <?php

                $sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";

                $result = $conn->query($sql);


                if ($result->num_rows > 0) {

                while($row = $result->fetch_assoc())
                {

                ?>
                <div class="col-sm-12">
                <h1> <?php echo $row["codiceCommessa"] . '-' . $row["nomeCantiere"] ?></h1>
                </div>
                <?php
                }

                } else {

                echo "0 results";

                }

                ?>
                </div>

                <?php
                $sql1 = "SELECT idAffidataria,nomeCantiere FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
                $result1 = $conn->query($sql1);


                if ($result1->num_rows > 0)
                {
                // output data of each row
                while($row1 = $result1->fetch_assoc())
                {

                ?>
                <div class="row">

                <div class="col-sm-11 offset-sm-1">

                <h1>Affidataria</h1>
                <a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria= <?php echo $row1["idAffidataria"] ?>">
                <?php echo $row1["nomeCantiere"] ?>
                </a>

                </div>


                <div class="col-sm-6 offset-sm-2">
                <h1>SubAffidatario</h1>

                <?php

                $idAffidataria = $row1["idAffidataria"];

                $sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
                $result2 = $conn->query($sql2);

                if ($result2->num_rows > 0)
                {
                // output data of each row
                while($row2 = $result2->fetch_assoc())
                {
                ?>
                <div class="col-sm-10">
                <br>
                <a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=<?php echo $row2["ragioneSocialeSubAffidatario"] ?>">
                <?php echo $row2["ragioneSocialeSubAffidatario"] ?>

                </a>
                </div>
                <?php
                }

                }else {
                echo "0 results";
                }

                }

                ?>
                </div>
                <?php

                }else{

                echo "0 results";

                }

                $conn->close();

                ?>

                </div>
                </div>

                </body>

                </html>





                share|improve this answer




























                  0












                  0








                  0







                  Try this, but I'm not sure if it's what you asked for, because I did not understand what you wanted.



                      <?php 

                  session_start();

                  if(!isset($_SESSION["username"])){
                  header('location: ../index.php');
                  }



                  $servername = "localhost";
                  $username = "root";
                  $password = "";
                  $dbname = "my_progettocantiere";



                  $idCantiere = $_GET["idCantiere"];

                  // Create connection
                  $conn = new mysqli($servername, $username, $password, $dbname);

                  // Check connection
                  if ($conn->connect_error)
                  {
                  die("Connection failed: " . $conn->connect_error);
                  }

                  ?>

                  <!DOCTYPE html>

                  <html lang="en">

                  <head>

                  <meta charset="utf-8">
                  <meta http-equiv="X-UA-Compatible" content="IE=edge">
                  <meta name="viewport" content="width=device-width, initial-scale=1">
                  <title>Progetto Cantiere</title>
                  <!-- Bootstrap -->
                  <link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
                  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">


                  </head>

                  <body>

                  <div class="container">

                  <div class="row">

                  <?php

                  $sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";

                  $result = $conn->query($sql);


                  if ($result->num_rows > 0) {

                  while($row = $result->fetch_assoc())
                  {

                  ?>
                  <div class="col-sm-12">
                  <h1> <?php echo $row["codiceCommessa"] . '-' . $row["nomeCantiere"] ?></h1>
                  </div>
                  <?php
                  }

                  } else {

                  echo "0 results";

                  }

                  ?>
                  </div>

                  <?php
                  $sql1 = "SELECT idAffidataria,nomeCantiere FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
                  $result1 = $conn->query($sql1);


                  if ($result1->num_rows > 0)
                  {
                  // output data of each row
                  while($row1 = $result1->fetch_assoc())
                  {

                  ?>
                  <div class="row">

                  <div class="col-sm-11 offset-sm-1">

                  <h1>Affidataria</h1>
                  <a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria= <?php echo $row1["idAffidataria"] ?>">
                  <?php echo $row1["nomeCantiere"] ?>
                  </a>

                  </div>


                  <div class="col-sm-6 offset-sm-2">
                  <h1>SubAffidatario</h1>

                  <?php

                  $idAffidataria = $row1["idAffidataria"];

                  $sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
                  $result2 = $conn->query($sql2);

                  if ($result2->num_rows > 0)
                  {
                  // output data of each row
                  while($row2 = $result2->fetch_assoc())
                  {
                  ?>
                  <div class="col-sm-10">
                  <br>
                  <a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=<?php echo $row2["ragioneSocialeSubAffidatario"] ?>">
                  <?php echo $row2["ragioneSocialeSubAffidatario"] ?>

                  </a>
                  </div>
                  <?php
                  }

                  }else {
                  echo "0 results";
                  }

                  }

                  ?>
                  </div>
                  <?php

                  }else{

                  echo "0 results";

                  }

                  $conn->close();

                  ?>

                  </div>
                  </div>

                  </body>

                  </html>





                  share|improve this answer















                  Try this, but I'm not sure if it's what you asked for, because I did not understand what you wanted.



                      <?php 

                  session_start();

                  if(!isset($_SESSION["username"])){
                  header('location: ../index.php');
                  }



                  $servername = "localhost";
                  $username = "root";
                  $password = "";
                  $dbname = "my_progettocantiere";



                  $idCantiere = $_GET["idCantiere"];

                  // Create connection
                  $conn = new mysqli($servername, $username, $password, $dbname);

                  // Check connection
                  if ($conn->connect_error)
                  {
                  die("Connection failed: " . $conn->connect_error);
                  }

                  ?>

                  <!DOCTYPE html>

                  <html lang="en">

                  <head>

                  <meta charset="utf-8">
                  <meta http-equiv="X-UA-Compatible" content="IE=edge">
                  <meta name="viewport" content="width=device-width, initial-scale=1">
                  <title>Progetto Cantiere</title>
                  <!-- Bootstrap -->
                  <link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
                  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">


                  </head>

                  <body>

                  <div class="container">

                  <div class="row">

                  <?php

                  $sql = "SELECT idCantiere,nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere WHERE idCantiere = '$idCantiere'";

                  $result = $conn->query($sql);


                  if ($result->num_rows > 0) {

                  while($row = $result->fetch_assoc())
                  {

                  ?>
                  <div class="col-sm-12">
                  <h1> <?php echo $row["codiceCommessa"] . '-' . $row["nomeCantiere"] ?></h1>
                  </div>
                  <?php
                  }

                  } else {

                  echo "0 results";

                  }

                  ?>
                  </div>

                  <?php
                  $sql1 = "SELECT idAffidataria,nomeCantiere FROM Affidataria WHERE fkIDCantiere = '$idCantiere'";
                  $result1 = $conn->query($sql1);


                  if ($result1->num_rows > 0)
                  {
                  // output data of each row
                  while($row1 = $result1->fetch_assoc())
                  {

                  ?>
                  <div class="row">

                  <div class="col-sm-11 offset-sm-1">

                  <h1>Affidataria</h1>
                  <a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria= <?php echo $row1["idAffidataria"] ?>">
                  <?php echo $row1["nomeCantiere"] ?>
                  </a>

                  </div>


                  <div class="col-sm-6 offset-sm-2">
                  <h1>SubAffidatario</h1>

                  <?php

                  $idAffidataria = $row1["idAffidataria"];

                  $sql2 = "SELECT * FROM SubAffidatario WHERE fkIdAffidataria = '$idAffidataria'";
                  $result2 = $conn->query($sql2);

                  if ($result2->num_rows > 0)
                  {
                  // output data of each row
                  while($row2 = $result2->fetch_assoc())
                  {
                  ?>
                  <div class="col-sm-10">
                  <br>
                  <a class="myButton" href="../../pagineHtml/visualizza/visualizzazione/affidatario.php?idAffidataria=<?php echo $row2["ragioneSocialeSubAffidatario"] ?>">
                  <?php echo $row2["ragioneSocialeSubAffidatario"] ?>

                  </a>
                  </div>
                  <?php
                  }

                  }else {
                  echo "0 results";
                  }

                  }

                  ?>
                  </div>
                  <?php

                  }else{

                  echo "0 results";

                  }

                  $conn->close();

                  ?>

                  </div>
                  </div>

                  </body>

                  </html>






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 21 '18 at 22:41

























                  answered Nov 21 '18 at 21:24









                  ErDiabloErDiablo

                  1355




                  1355






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419986%2fdynamic-table-with-html-and-php%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

                      Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

                      A Topological Invariant for $pi_3(U(n))$