• Resolved 0cg0

    (@0cg0)


    Hi Tobias,

    how can I check if a value passed in a form exists in a table?

    Basically, I have a page with a form that has only one field where I enter the value I want to search for in the table, and if it exists, with a shortcode, I render the table and the record on the page.

    I’m not sure if my approach is correct: the form field is called ‘table_filter’; the form submits the field using the GET method; on the same page, I have a shortcode [table_filter id=3333 filter_full_cell_match=true /] that renders the table and a shortcode [test_table_cell id=3333 column=1 /] […2/] that renders the requested record.

    Problem: if ‘table_filter’ is not present in table 3333, an empty table is still displayed, but I need to display a message like “Code does not exist” rather than an empty table. I have tried several functions, but I can’t verify if the value exists and therefore cannot control the feedback to provide to the user and what to display on the page. I hope you can help me.

    Thank you in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    This is indeed not directly possible with the now retired and outdated Row Filtering Extension that you are using. This will no longer receive updates or support, as these features have been integrated and highly improved in the TablePress premium versions, see https://tablepress.org/premium/. Thus, the retired TablePress Extensions that you are using are now part of https://tablepress.org/modules/row-filtering/ You would need a TablePress Pro or Max license (via https://tablepress.org/pricing/) for this. If you have further questions regarding that, please get in touch (e.g. via the email address from the bottom part of that link). Thanks!

    Best wishes,
    Tobias

    Thread Starter 0cg0

    (@0cg0)

    Ok, I think I’ll subscribe.

    But I wanted to ask if I can use TablePress PHP functions to read table from code?
    Tried this
    $table_id = '123';
    $num = $_GET['table_filter’];
    $table = TablePress::$model_table->load( $table_id, true, false );
    if ( $num === $table[0][0] ) {
    echo 'found';
    }

    but it does not work!
    Thank you.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    you will need to use $table['data'][0][0] here, which contains the actual data. The other entries in that array also contain table name, description, options, etc.

    Regards,
    Tobias

    Thread Starter 0cg0

    (@0cg0)

    Hi,

    with a little tweaking it worked.

    Thank you

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Check existing data in table’ is closed to new replies.