• Resolved Hybreeder

    (@hybreeder)


    Hi,
    I uploaded the table in the table press. There is no issue.
    Is it possible to fetch the table and display on php page?

    If yes then please suggest me how to fetch the table from the table press

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    This depends on how your PHP script is integrated in your WordPress site. If done properly, like a plugin using the API, you could use TablePress Template Tag functions, like tablepress_print_table( array( 'id' => '1' ) );.

    Regards,
    Tobias

    Thread Starter Hybreeder

    (@hybreeder)

    @tobiasbg,
    I apologize for the late reply.

    I installed the Tablepress plugin and import my table. There is no issue till now.

    Now I have a file called list.php which is outside of the WordPress folder and I have to show my table in that file.

    I know how to fetch the data from the database. my issue is, what query do I have to use it to show the list? what table name and Id I have to use to fetch?

    select * from tablepresstable

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    Sorry, that will not work. TablePress does not store the data in a custom mySQL table, but as a JSON-encoded array in the wp_posts database table. Then, it uses PHP to render the HTML code, which is done by the function from my example above.

    If you want to use a database, you should do so directly, outside of TablePress.

    Regards,
    Tobias

    Thread Starter Hybreeder

    (@hybreeder)

    @tobiasbg , Ok, I tried the below code in the PHP page

    
    $query="SELECT * FROM<code>wp_posts</code> where ID=30";
    try {
              $stmt = $pdo->prepare($query);
              $stmt->execute();
              $row = $stmt->fetch();
    
            $arr_result= array(
                        "id" =>$row['ID'],
                        "postcontent" => $row['post_content']
                         );
        
            }
            catch(PDOException $e) {
                echo "Error: " . $e->getMessage();
            }
    
            print_r($arr_result);

    and I am getting my output like

    Array ( 
           [id] => 30 
           [postcontent] => [
                              ["Name","Industry","Number","Website"],
                              ["pqr","Other","10","pqr.com"],
                              ["lmn","Other","15","lmn.com"],
                              ["xyz","Other","20","xyz.com"],
                            ] 
    
                )

    Now I have to find out how to show postcontent in the HTML table

    • This reply was modified 3 years, 1 month ago by Hybreeder.
    • This reply was modified 3 years, 1 month ago by Hybreeder.
    • This reply was modified 3 years, 1 month ago by Hybreeder.
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    again, I don’t recommend this approach, and I can not offer support for it, but if you really have to, you can try reusing the code of the classes/class-render.php file.

    Regards,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to fetch the table from the table press and display on PHP page?’ is closed to new replies.