WP Plugin Pull out data from db for edit or delete

enter image description here

Hey Guys, hopefully you can help. this is my first WP Plugin, and it allows user to add car details to a DB which works fine, then outputs those details to a page.

Read More

I can add cars just fine, but now I need to be able to delete them and edit them. And this is where im a little stumped… to edit, i want to click on the item from the list up the top and its details be placed in the fields below, edit then click save to update it.

but im struggling to find out how to grab the data? should i be using Ajax or is there another way?

thanks.

Related posts

Leave a Reply

1 comment

  1. I have created such plugin without using ajax
    In the table I’ve created 2 links – “edit” and “delete”, and sent the id of the element

    <a href="admin.php?page=film_add&act=upd&id=<?php echo $id;?>">Edit</a>
    <a href="admin.php?page=myplug/muyplg.php&info=del&did=<?php echo $id;?>">Delete</a>
    

    if $info=del

    if($info=="del")
    {
        $delid=$_GET["did"];
        $wpdb->query("delete from ".$table_name." where id=".$delid);
    }
    

    and similarly for “edit”

    $act=$_REQUEST["act"];
    if($act=="upd")
    {
        $recid=$_REQUEST["id"];
        $sqlL="select * from ".$table_name = $wpdb->prefix . "member where id=$recid";
        $result = mysql_query($sqlL) or die ('Error, query failed');
        if (mysql_num_rows($result) > 0 )
        {
            if($row = mysql_fetch_assoc($result))
            {
                $id        = $row['id'];
                $film_name      = $row['film_name'];
                // etc
            }
        }
    }
    

    And also I’ve added submenu page, where I’m adding or editing records