0
I have a system that lists the fields and attributes of a table through javascript and ajax up to there everything, only that the elements created and listed in precise runtime manipulates lós through a selector as I do to get this selector as id ?
This is the code I use to display the fields:
if($_POST['op']=='bancopesquisartabelas'){
$pdo = new PDO(DB_SERVER.":host=".DB_HOST.";dbname=".$_POST['bancotabelas'],DB_USER,DB_PASSWORD);
$sql = $pdo->prepare("SHOW TABLES FROM ".$_POST['bancotabelas']);
$sql->execute();
foreach($sql as $obj){
echo '<option value="'.$obj[0].'">'.$obj[0].'</option>';
} $pdo = null;
} else if ($_POST['op']=='mostarcampos'){
$_SESSION['bancotabelas']=$_POST['bancotabelas'];
$_SESSION['tabelasbanco']=$_POST['tabelasbanco'];
$pdo = new PDO(DB_SERVER.":host=".DB_HOST.";dbname=".$_POST['bancotabelas'],DB_USER,DB_PASSWORD);
$sql = $pdo->prepare("SHOW FIELDS FROM ".$_POST['tabelasbanco']);
$sql->execute();
foreach($sql as $obj){
echo'
<input id="'.$obj[0].'" type="text" class="form-control" value="'.$obj[0].'" placeholder="'.$obj[0].'" style="width:150px">
<input id="'.$obj[1].'" type="text" class="form-control" value="'.$obj[1].'" placeholder="'.$obj[1].'" style="width:150px">
<input id="'.$obj[2].'" type="text" class="form-control" value="'.$obj[2].'" placeholder="'.$obj[2].'" style="width:150px">
<input id="'.$obj[3].'" type="text" class="form-control" value="'.$obj[3].'" placeholder="'.$obj[3].'" style="width:150px">
<input id="'.$obj[4].'" type="text" class="form-control" value="'.$obj[4].'" placeholder="'.$obj[4].'" style="width:150px">
<input id="'.$obj[5].'" type="text" class="form-control" value="'.$obj[5].'" placeholder="'.$obj[5].'" style="width:150px">
<button id="updatetabela" class="btn btn-default">Alterar</button>
';
}
}
through it I select the bank and the table and it lists for me its fields and attributes I need to get their id when they are created to trigger an event with the button and be able to change the table, I appreciate the help.
this ID there that I want to take when I choose the bank and the table it is generated.