Support » Plugins » Hacks » wpdb – how can I make text link to delete rows in two tables?

  • jlknauff

    (@jlknauff)


    How can I make a text link to delete rows in two tables? I want it to work the same way as the red “x” in phpMyAdmin. One row would be in wp_posts, the other in a non-standard table.

    Any insight?

Viewing 1 replies (of 1 total)
  • Can’t help you with the non-standard table…
    You can make a button to delete rows on the front end…
    Put this in your page template…I made a new template to show/deal with tables.

    <a href="">
           <input type="submit" name="Whitetemp" value=" Delete Data " onclick="<?php delete_data_func(); ?>" />
    </a>

    Then make a function to delete your row in your table either in your functions.php or in a plugin

    function delete_data_func()	{
    	global $wpdb;
    	$wpdb->query(" DELETE FROM your_table_name WHERE ID = '1' ");
    }

    WHERE ID is the row/entry’s ID that you want to delete

Viewing 1 replies (of 1 total)
  • The topic ‘wpdb – how can I make text link to delete rows in two tables?’ is closed to new replies.