Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table width="100%" border="0" cellspacing="0" cellpadding="0">
- <thead>
- <tr>
- <th>id</th>
- <th>nome</th>
- <th>botao</th>
- </tr>
- </thead>
- <tbody>
- <?php $tab = pg_query($db,"select id, nome from tabela"); while($tabRow = pg_fetch_assoc($tab)){ ?>
- <form>
- <tr>
- <td><?php echo $tabRow['id'];?></td>
- <td><?php echo $tabRow['nome'];?></td>
- <td><button type="button" id="<?php echo $tabRow['id'];?>" name="btn" onclick="btn(this)">consultar</button></td>
- </tr>
- </form>
- <?php } ?>
- </tbody>
- </table>
- <div id="mostra"></div>
- <br />
- <!-- resultado a ser mostrado -->
- <form>
- <input type="id" name="id" value=""<br />
- <input type="nome" name="nomr" value=""<br />
- <img id="imagem" src=""/>
- </form>
- <script>
- function btn(e){
- var txt = $(e).attr('id');
- $.ajax({
- type: 'post',
- url: 'tabela.php',
- data: {id: txt},
- beforeSend: function() { $("#loader").show(); },
- success: function(data) { $("#loader").hide(); }
- })
- .done(function(data){
- $("#mostra").html(data);
- //$("#form")[0].form.reset();
- });
- }
- </script>
- if(isset($_POST['id'])){
- $sql = pg_query($db,"select id, nome, encode(lo_get(imagem),'base64') as imagem, extensao from tabela where id = ".$_POST['id']."");
- $sqlRow = pg_fetch_assoc($sql);
- echo '<script>
- $(function(){
- $("#id").val("'.$sqlRow ['id'].'");
- $("#nome").val("'.$sqlRow ['nome'].'");
- $("#imagem").attr("src","data:image/'.$sqlRow ['extensao'].';base64,'.$sqlRow ['imagem'].'");
- });
- </script>';
- }
Add Comment
Please, Sign In to add comment