Hi there, this is the code I have set up to retrieve project details from the database.
Currently the
Customer = customers_id displayed from the customers table
Architect = suppliers_id displayed from the suppliers table
Structural Engineer = suppliers_id shown from the suppliers table
I would like to change the all id’s to the full_name column on respective tables (Customer to customers.customers_full_name and Architect and Structural Engineer to suppliers.suppliers_full_name)
I think this needs to be done as a JOIN but am really struggling to get it all working. I can get customer done and Architect but cant seem to join two fields to one table/column.
Any help would be appreciated.
<title>Theme Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap theme -->
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/theme.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
  
  
  <?php include 'db/connection.php';
  ?>
  <?php
  $projectid=$_GET['id'];
  ?>
<nav class="navbar navbar-inverse navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="http://localhost/belmore/">Belmore</a>
    </div>
    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
                  <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Menu <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
          </ul>
        </li>
      </ul>
    </div><!--/.nav-collapse -->
  </div>
</nav>
<div class="container theme-showcase" role="main">
	<div class="page-header">
		<h1>View Project</h1>
	</div>
		<div class="col-md-10">
			<table class="table table-striped">
				<thead>
					<tr>
						<th>id</th>
						<th>Project Name</th>
						<th>Project Number</th>
						<th>Customer</th> 
						<th>Architect</th>
						<th>Structural Engineer</th>				
					</tr>
				</thead>
				<tbody>
					<?php
					$sql = "SELECT *
   					FROM projects
   				    WHERE projects_id = $projectid";
					$result = $conn->query($sql);
						if ($result->num_rows > 0)
						{
					// output data of each row
						while($row = $result->fetch_assoc())
						{
							echo '<tr>';
							echo '<td>' . $row['projects_id']. '</td>';
							echo '<td>' . $row['projects_name']. '</td>';
							echo '<td>' . $row['projects_number']. '</td>';
							echo '<td>' . $row['projects_customer']. '</td>';
							echo '<td>' . $row['projects_architect']. '</td>';
							echo '<td>' . $row['projects_structural_engineer']. '</td>';
							echo '</tr>';
						}
							} else {
							echo "0 results";
									}
					?>
				</tbody>
			</table>
		</div>
	</div>
 
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="js/bootstrap.min.js"></script>
<script src="js/docs.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>