I have a system that clears the fields and attributes of a table via javascript and ajax so far, but the elements created and listed at the precise execution time manipulate them through a selector like I do to pick up that selector like 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>
';
}
}
>
This ID is what I want to get when I choose the database and the table it generates.