Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function eg_update_cidade (){
- global $wpdb;
- $id = $_GET["id"];
- $set_nome=$_POST["nome_cidade"];
- $set_estado=$_POST["estado"];
- //update
- if(isset($_POST['update'])){
- $wpdb->update(
- 'cidade', //table
- array('nome_cidade' => $set_nome), //data
- array('estado' => $set_estado), //data
- array( 'id_cidade' => $id ), //where
- array('%s'), //data format
- array('%s'), //data format
- array('%s') //where format
- );
- }
- //delete
- else if(isset($_POST['delete'])){
- $wpdb->query($wpdb->prepare("DELETE FROM cidade WHERE id_cidade = %s",$id));
- }
- else{//selecionando valor para atualizar
- $cidades = $wpdb->get_results($wpdb->prepare("SELECT id_cidade,nome_cidade,estado from cidade where id_cidade=%s",$id));
- foreach ($cidades as $s ){
- $nome=$s->nome_cidade;
- }
- }
- ?>
- <link type="text/css" href="<?php echo WP_PLUGIN_URL; ?>/GerePRO/style-admin.css" rel="stylesheet" />
- <div class="wrap">
- <h2>Cidades</h2>
- <?php if($_POST['delete']){?>
- <div class="updated"><p>Cidade Deletada</p></div>
- <a href="<?php echo admin_url('admin.php?page=lista_cidades')?>">« Voltar para Lista de Cidades</a>
- <?php } else if($_POST['update']) {?>
- <div class="updated"><p>Cidade Atualizada</p></div>
- <a href="<?php echo admin_url('admin.php?page=lista_cidades')?>">« Voltar para Lista de Cidades</a>
- <?php } else {?>
- <form method="POST" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
- <table class='wp-list-table widefat fixed'>
- <tr><th>Nome</th><td><input type="text" name="nome_cidade" value="<?php echo $set_nome;?>"/></td></tr>
- <tr><th>Estado</th><td><input type="text" name="estado" value="<?php echo $set_estado;?>"/></td></tr>
- </table>
- <input type='submit' name="update" value='Save' class='button'>
- <input type='submit' name="delete" value='Delete' class='button' onclick="return confirm('¿Confirma Exclusão?')">
- </form>
- <?php }?>
- </div>
- <?php
- }
Advertisement
Add Comment
Please, Sign In to add comment