COMO FAZER UPDATE DENTRO DO MODAL OU DIV

HTML

MySQL

PHP

07/05/2019

<?php
	

	$pdo = new PDO(''''''''mysql:host=localhost;dbname=db_sistema'''''''', ''''''''root'''''''',  '''''''' '''''''');
	$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	$pdo->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES ''''''''utf8''''''''");

	if (isset($_POST[''''''''retornar''''''''])) {

		if (isset($_POST[''''''''numero''''''''])) {
			$numero = $_POST[''''''''numero''''''''];
			$pdoStatement = $pdo->query("SELECT * FROM `area123_clientes` WHERE numero = $numero ");
    		$row = $pdoStatement->fetch(PDO::FETCH_ASSOC);
    		echo("\\\\\\\\\\\\\\\\n {$row[''''''''numero'''''''']}");
    		echo "<br>";
    		echo("\\\\\\\\\\\\\\\\n {$row[''''''''name'''''''']}");
    		
		}
	} else {
    	echo "OpS! Não conseguimos encontrar no banco de dados.";;
	}
?>


<!DOCTYPE html>
<html lang="pt-br">
    <head>
        <title>Form de exemplo com checkboxes</title>
        <meta charset="utf-8">
    </head>

    <body>

        <form action="" method="post">
        	<p>  <input type="text" name="numero">  </p>
                <p> <input type="submit" name="retornar" value="ENVIAR" />   </p>
        </form>

        <tbody id="myTable" class="col-12">	

		<tr>
			<td><?php echo("\\\\\\\\\\\\\\\\n {$row[''''''''numero'''''''']}"); ?></td>
			<td>
				<button type="button" class="btn btn-primary" 
				data-toggle="modal" data-target="#exampleModal" 
				data-whateverid="<?php  echo(" {$row[''''''''numero'''''''']} "); ?>" 
				data-whatevernome="<?php echo( "{$row[''''''''nome'''''''']} "); ?>" 
			  >EDITAR</button>

			</td>
		</tr>


			<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
			  <div class="modal-dialog" role="document">
			    <div class="modal-content">
			      <div class="modal-header">
			        <h5 class="modal-title" id="exampleModalLabel">CARTÕES EMITIDOS</h5>
			        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
			          <span aria-hidden="true">×</span>
			        </button>
			      </div>
			      <div class="modal-body">
			        <form method="POST" action="registrar_teste.php">

			        	<label for="recipient-id" class="col-form-label">CLIENTE: </label>
			            <input type="text" class="form-control" id="recipient-id" name="id" >

			            <label for="recipient-nome" class="col-form-label">NOME:</label>
			            <input type="text" class="form-control" id="recipient-nome" name="nome" >
			        
			        	<button type="button" class="btn btn-secondary" data-dismiss="modal">CANCELAR</button>
			        	<button type="submit" class="btn btn-primary">SALVAR ALTERAÇÕES</button>
		

			        </form>
			      </div>
			      
			    </div>
			  </div>
			</div>


</tbody>

        	
  
 ?>

	<script type="text/javascript">
		$(''''''''#exampleModal'''''''').on(''''''''show.bs.modal'''''''', function (event) {
			var button = $(event.relatedTarget) // Button that triggered the modal
			var id = button.data(''''''''whateverid'''''''') // Extract info from data-* attributes
			var nome = button.data(''''''''whatevernome'''''''') // Extract info from data-* attributes
			var emitido = button.data(''''''''whateveremitido'''''''') // Extract info from data-* attributes
			// If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
			// Update the modal''''''''s content. We''''''''ll use jQuery here, but you could use a data binding library or 	other methods instead.
			var modal = $(this)
			modal.find(''''''''.modal-title'''''''').text(''''''''NOME: '''''''' + nome)
			modal.find(''''''''#recipient-id'''''''').val(id)
			modal.find(''''''''#recipient-nome'''''''').val(nome)
		})
	</script>


    </body>
</html>



-----------------------------------

em meu registrar_teste.php


<?php 

	$pdo = new PDO(''''''''mysql:host=localhost;dbname=db_sistema'''''''', ''''''''root'''''''', '''''''''''''''');
	//$pdo = new PDO(''''''''mysql:host=localhost;dbname=db_sistema'''''''', ''''''''allison'''''''', ''''''''0471@marqs'''''''');
	$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	$pdo->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES ''''''''utf8''''''''");


	if (isset($_POST[''''''''email''''''''])) {

		if (isset($_POST[''''''''email''''''''])) {
			$numero = $_POST[''''''''email''''''''];
			$numero = $pdo->query("UPDATE area123_clientes SET email=''''''''$email'''''''' WHERE id=''''''''$id'''''''' ");
    		$row = $numero->fetch(PDO::FETCH_ASSOC);
    		echo("\\\\\\\\\\\\\\\\n {$row[''''''''numero'''''''']}");
    		echo "<br>";
    		echo("\\\\\\\\\\\\\\\\n {$row[''''''''name'''''''']}");
    
		}

	} else {
    	echo "OpS! Não conseguimos encontrar no banco de dados.";
    	header("Location: teste.php");
	}

?>

Allison Marques

Allison Marques

Curtidas 0

Respostas

Allison Marques

Allison Marques

07/05/2019

Não está com varias aspas. Meu primeiro post :)
GOSTEI 0
POSTAR