Meu select está errado. Como faço para visualizar os dependentes deste usuário: eu tenho 1 usuário: (Mauro Santos) e 2 Dependentes: (Thiago e Dhalila), como faço para visualizar na view.
Select
SELECT * FROM cad_lideranca WHERE numerocontrato = :numerocontrato
Código da View
<?php
require_once './config.php';
include './header.php';
try {
$sql = "SELECT * FROM cad_lideranca WHERE numerocontrato = :numerocontrato";
$stmt = $DB->prepare($sql);
$stmt->bindValue(":numerocontrato", intval($_GET["numerocontrato"]));
$stmt->execute();
$results = $stmt->fetchAll();
} catch (Exception $ex) {
echo $ex->getMessage();
}
?>
<div class="row">
<ul class="breadcrumb">
<li><a href="index.php">Início</a></li>
<li class="active">Informações</li>
</ul>
</div>
<div class="row">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Informações</h3>
</div>
<div class="panel-body">
<form class="form-horizontal" name="contact_form" id="contact_form" enctype="multipart/form-data" method="post" action="process_form.php">
<fieldset>
<div class="form-group">
<label class="col-lg-4 control-label"><span class="required"></span>Número do Contrato:</label>
<div class="col-lg-5">
<input type="text" readonly="" placeholder="Número do Contrato" value="<?php echo $results[0]["numerocontrato"] ?>" id="numerocontrato" class="form-control" name="numerocontrato"><span class="error"></span>
</div>
</div>
<div class="form-group">
<label class="col-lg-4 control-label"><span class="required"></span>Responsável:</label>
<div class="col-lg-5">
<input type="text" readonly="" value="<?php echo $results[0]["nomecompleto"] ?>" placeholder="Responsável" id="nome_completo" class="form-control" name="nome_completo"><span class="error"></span>
</div>
</div>
<div class="form-group">
<label class="col-lg-4 control-label"><span class="required"></span>E-mail:</label>
<div class="col-lg-5">
<input type="text" readonly="" value="<?php echo $results[0]["email"] ?>" placeholder="E-mail" id="email" class="form-control" name="email"><span class="error"></span>
</div>
</div>
<div class="form-group">
<label class="col-lg-4 control-label"><span class="required"></span>Estado:</label>
<div class="col-lg-5">
<input type="text" readonly="" value="<?php echo $results[0]["estado"] ?>" placeholder="Estado" id="email" class="form-control" name="email"><span class="error"></span>
</div>
</div>
<div class="form-group">
<label class="col-lg-4 control-label"><span class="required"></span>Valor da Adesão:</label>
<div class="col-lg-5">
<input type="text" readonly="" value="<?php echo $results[0]["adesao"] ?>" placeholder="Adesão" id="adesao" class="form-control" name="adesao"><span class="error"></span>
</div>
</div>
<div class="form-group">
<label class="col-lg-4 control-label"><span class="required"></span>Valor Total:</label>
<div class="col-lg-5">
<input type="text" readonly="" value="<?php echo $results[0]["total"] ?>" placeholder="Total" id="total" class="form-control" name="total"><span class="error"></span>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
<!-- DEPENDENTES -->
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Dependentes</h3>
</div>
<div class="panel-body">
<div class="col-lg-12" style="padding-left: 0; padding-right: 0;" >
<form action="index.php" method="get" >
<div class="col-lg-6 pull-left"style="padding-left: 0;" >
<span class="pull-left">
</div>
</form>
</div>
<div class="clearfix"></div>
<?php if ($results > 0) { ?>
<div class="table-responsive">
<table class="table table-striped table-hover table-bordered ">
<tbody><tr>
<th>Nome do Dependente</th>
<th>CPF</th>
<th>Plano </th>
<th>Acomodação </th>
<th>Grau Parentesco </th>
<th>Valor do Dependente </th>
</tr>
<?php foreach ($results as $res) { ?>
<tr>
<td><?php echo $res["nomedependente"]; ?></td>
<td><?php echo $res["cpfdependente"]; ?></td>
<td><?php echo $res["planodependente"]; ?></td>
<td><?php echo $res["acomodacaodependente"]; ?></td>
<td><?php echo $res["grauparentescodependente"]; ?></td>
<td><?php echo $res["valordependente"]; ?></td>
</tr>
<?php } ?>
</tbody></table>
</div>
<?php } else { ?>
<div class="well well-lg"><b>Nenhum dependente encontrado.</b></div>
<?php } ?>
</div>
</div>
</div>
id
é do dependente certo? qual é o campo que associa o dependente ao responsavel? número do contrato?