• Resolved dedemo

    (@dedemo)


    Hi! I feel I’m close on this, but I am totally missing something.

    I have on one page a form where I simply want someone to enter a surname, if they want to, as the table grows. Then below the form are the results of the query. I do want all rows to populate by default.

    I have tried the php gets and I’m about to beat my head against the wall. Thinking that within the SQL query report that the where statement needs to include a link to the page….But I get “no results” and if the form has nothing entered, I want it to show all values.

    Okay, Here is the code I have on Surname-Search page:
    <form action=”” method=”post”>Search Surname: <input name=”searchsurname” type=”search” /> <input type=”submit” value=”Submit” /></form></br>
    [SQLREPORT name=”test-surname-list”]

    Now here is the query in the SQLReport as it is now that works:
    SELECT CONCAT(‘‘,’‘,’‘) as ‘Email’, surname as ‘Surname’, county as ‘County’, state, country as ‘Country’, yearbegin as ‘Begin Year’, yearend as ‘End Year’ from database.wp_surnames ORDER By surname

    The following is just one of the Select statements I’ve tried:
    [$query = $_GET[“https://website/surname-search2/searchsurname”];
    echo ELISQLREPORTS_view_report(“”, “SELECT CONCAT(‘‘,’‘,’‘) as ‘Email’, surname as ‘Surname’, county as ‘County’, state as ‘State/Prov/Reg’, country as ‘Country’, yearbegin as ‘Begin Year’, yearend as ‘End Year’ from database.wp_surnames WHERE (surname ='<?php $query?>’)”);]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter dedemo

    (@dedemo)

    Okay. I’m making slowly making progress. Have it where I can filter the surname.
    For one, I moved the WHERE statement before ORDER BY…duh :
    WHERE surname = ‘<?php $_GET[searchsurname] ?>’ ORDER BY surname

    However, I want to show all the data be default until someone enters the information. In your plugin, how can get the WHERE statement stated correctly, so that if GET[searchsurname] is empty it shows everything?

    Plugin Author Eli

    (@scheeeli)

    You can use this”
    WHERE surname = ‘<?php $_GET[searchsurname] ?>’ OR ” = ‘<?php $_GET[searchsurname] ?>’ ORDER BY surname

    Thread Starter dedemo

    (@dedemo)

    Thank you!!! I was working on something like this Friday, but couldn’t quite get the syntax down.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Passing Search form to database query’ is closed to new replies.