When i fetch data from wpdb i got the table like below

Name          Description             Product                     Action
name1       description here        product 1                edit     delete
name1      description here         product 2                edit     delete

but, i want to display the table like this. i am not able to fetch data like below table. help me out

Name          Description             Product                     Action
name1       description here         product 1                edit     delete
                                     product 2      

Here is my code

    $output ='<table class="table table-striped custab campaign">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Description</th>
                            <th>Product</th>
                            <th>Action</th>
                        </tr>
                    </thead>';
        global $wpdb;
        $rows = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "table_name");
                    foreach ($rows as $row){     

$output .= '<tr id="campaign_delete">';
                        $output .= '<td>'.$row->name.'</td>';
                        $output .= '<td>'.$row->description.'</td>';
                        $output .= '<td>'.$row->product.'</td>';
                        $output .= '<td class="text-center">
                        <a class="btn btn-info btn-xs"href="">edit</a> 
                        <a href="" class="btn btn-danger btn-xs" >delete</a></td>

                             </tr>';
                    }
                    $output .= '</table>';
                    echo $output;   

Read more here: Merge wordpress custom table


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: