Good morning companions (here it's just 10am), to see if they can help me, because I do not know why the code does not work and I explain the code in a table I have "X" name let's say brands when I click on the brand, you must show me all the products that I have of that brand at the same time I will put both codes that I use.
<table class="table table-hover table-bordered"style="overflow:auto;width:100%;font-size:80%; border-collapse:collapse; margin-bottom:10px;box-shadow:5px 5px 5px grey;border: 1px solid blue;margin-top:10px">
<thead><tr><td colspan="2" style="font-weight: bold;text-transform:uppercase;text-align:center;">Proyectos</td></tr></thead>
<?php while($sub=$db1->fetch(PDO::FETCH_ASSOC)){;?>
<tbody><tr><td style="overflow:auto;underline;cursor: pointer;color:blue;text-transform:uppercase;text-align:center;"onclick="proy1(<?php echo $sub['id_empresa'];?>)"><?php echo $sub['proyecto'];?></td>
<td style="text-align:right;"><button <button class="btn btn-danger glyphicon glyphicon-remove" data-toggle="modal"data-toggle="tooltip"title="Eliminar" onclick="eliminar(<?php echo $sub['id'];?>);"></button></td></tr><?php };?>
</tbody>
<!--<tfoot><tr><td>pie de pagina</td></tr></tfoot>--->
</table>
and with the script I use
function proy1(p){
var id=<?=$id;?>;
var p=p;
cadena="ids="+p+"&id="+id;
$.ajax({
type: "POST",
url: "mod_admin/tpl/config2.php",
data:cadena,
success: function(r){
alert(r);
$("#sub_proyecto").show();
}
})
};
This part works for me wonderfully and without problems because I have used the code before in other things now the code to show me the result is as follows:
if(isset($_POST['ids'])){
$ids=$_POST['ids'];}else{$ids=0;
};
$sql3="Select * from ".su." where id=".$ids;
$db2=$dbh->prepare($sql3);
$db2->execute();
<table class="table table-hover table-bordered"style="overflow:auto;width:100%;font-size:80%; border-collapse:collapse; margin-bottom:10px;box-shadow:5px 5px 5px grey;border: 1px solid blue;margin-top:10px">
<thead><tr><td colspan="2" style="font-weight: bold;text-transform:uppercase;text-align:center;">Sub Proyectos</td></tr></thead>
<tbody>
<tr>
<?php while($sub2=$db1->fetch(PDO::FETCH_ASSOC)){ ?>
<td>
<?php echo $sub2['proyecto'];?>
</td>
<td style="text-align:right;">
<button class="btn btn-danger glyphicon glyphicon-remove"
data-toggle="modal"data-toggle="tooltip"title="Eliminar"
onclick="eliminar1(<?=$sub2['id_proyecto'];?>);">
</button>
</td>
<?php };?>
</tr>
</tbody>
</table>
I already made a print_r to the result of the while and with the alert it shows me the perfect array, now because it does not work if in theory they are the same codes, to see if they can help me. Thanks