Show only filtered table
-
I have a form to filter a CFDB table but at the beginning, the table is showing all data. How can I show the table only if the form is submitted?
https://wordpress.org/plugins/contact-form-7-to-database-extension/
-
See this page: http://cfdbplugin.com/?page_id=680
at the end it describes how to add a hidden field which the filter checks.
Thank you so much for your answer Michael. It still doesn’t work. I have added the hidden field x to the form and the short code “&&submit_time>$_POST(x)” to the filter but it is still showing all results. I have version 2.9.4
Post your short code and form definition
Form:
<form action="" method="POST">Título: <input name="f2" type="text" value="Buscar…" />Tipo: <select name="f1"> <option value="Ninguno"></option> <option value="Columna">Columna</option> <option value="Artículo">Artículo</option> <option value="Investigación">Investigación</option> <option value="Libro">Libro</option> </select>Tema: <select name="f3"> <option value="Ninguno"></option> <option value="Arte">Arte</option> <option value="Drogas">Drogas</option> <option value="Narcotráfico">Narcotráfico y poder</option> <option value="Jóvenes">Jóvenes</option> <option value="Educación">Educación</option> <option value="Participación">Participación</option> <option value="Violencia">Violencia</option> </select> <input name="x" type="hidden" value="1" /> <input type="submit" value="Buscar" /></form>Short code:
[cfdb-table form=”Biblioteca Web” filter=”Titulo~~/.*$_POST(f2).*/i||Tipo=$_POST(f1)||Tema~~/.*$_POST(f3).*/&&submit_time>$_POST(x)” hide=”Submitted,Submitted Login,Submitted From”]
The problem is the use of OR (||) in the short code. You need to add the && constraint to each OR clause.
[cfdb-table form="Biblioteca Web" filter="Titulo~~/.*$_POST(f2).*/i&&submit_time>$_POST(x)||Tipo=$_POST(f1)&&submit_time>$_POST(x)||Tema~~/.*$_POST(f3).*/&&submit_time>$_POST(x)" hide="Submitted,Submitted Login,Submitted From"]Still showing all results. I just used the exactly code you post.
Let’s add some debug output using debug=”true”
[cfdb-table form="Biblioteca Web" filter="Titulo~~/.*$_POST(f2).*/i&&submit_time>$_POST(x)||Tipo=$_POST(f1)&&submit_time>$_POST(x)||Tema~~/.*$_POST(f3).*/&&submit_time>$_POST(x)" hide="Submitted,Submitted Login,Submitted From" debug="true"]It will print out some text about how it parses the filter. Post that.
'Titulo~~/.*.*/i&&submit_time>||Tipo~~/.*.*/i&&submit_time>||Tema~~/.*.*/&&submit_time>' Array ( [0] => Array ( [0] => Array ( [0] => Titulo [1] => ~~ [2] => /.*.*/i ) [1] => Array ( [0] => submit_time [1] => > [2] => ) ) [1] => Array ( [0] => Array ( [0] => Tipo [1] => ~~ [2] => /.*.*/i ) [1] => Array ( [0] => submit_time [1] => > [2] => ) ) [2] => Array ( [0] => Array ( [0] => Tema [1] => ~~ [2] => /.*.*/ ) [1] => Array ( [0] => submit_time [1] => > [2] => ) ) )im new to wordpress. How do I only select certain variables in the database table and add it into a post?
Like for example a user submits a new form and the details are automatically added to the database and the post itself. Is that possible with this plugin?
Also can i upload a document in the form?
HELP PLEASE!@farhanasyed88 start a new topic with your question. Look at the short code builder admin page.
Try this constraint instead:
[cfdb-table form="Biblioteca Web" filter="Titulo~~/.*$_POST(f2).*/i&&0<$_POST(x)||Tipo=$_POST(f1)&&0<$_POST(x)||Tema~~/.*$_POST(f3).*/&&0<$_POST(x)" hide="Submitted,Submitted Login,Submitted From" debug="true"]That will give you the initial form as empty. But when you submit, if you are not filling out all form fields, you will get all values because you end up with a field ~~/*.*/ which matches all values since you are using OR (||).
Yes! It’s working now!!
Thank you so much for your help!
The topic ‘Show only filtered table’ is closed to new replies.