Forums

wpdb - how can I make text link to delete rows in two tables? (2 posts)

  1. jlknauff
    Member
    Posted 1 year ago #

    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?

  2. jract7
    Member
    Posted 8 months ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags