0

I have a table in my wordpress install that stores a lot of data. I have a php file that can run a query on the table and return a nicely filtered selection of rows. I have a form on my wordpress page that allows users to select a variety of values corresponding to the mysql query variables. How do I get the php file to use the values selected in the form?

my form uses the following:

<input type="text" name="max_price" />
<input type="text" name="loan_fraction" />
<input type="text" name="interest_rate" />
<input type="text" list="state" />

I don't really know what sort of submit action I need but I want it to pass these values to my php that uses them like:

$values = mysql_query("select
    b.listing, b.bed, b.bath, b.type, b.address, b.postcode, b.state, b.price, avg_rent
from
    buy_items b
        join
    (SELECT
        bed, bath, type, suburb, postcode, AVG(price) as avg_rent
    FROM
        rent_items
    GROUP BY bed, bath , type , suburb , postcode) a ON a.bed = b.bed and a.bath = b.bath
        and a.suburb = b.suburb
        and a.postcode = b.postcode
    and a.type = b.type
where
    (b.price * some_number) < a.avg_rent
  and b.price > 50000
  and price < max_price
  and b.state = state");

where some_number is a function of loan_fraction and interest_rate.

Thanks :)

1
  • your question is ambigius, other thing is you should not use mysql_query in wordpress instead use $wpdb->query to make database queries . for more info google wordpress wpdb class Commented Nov 13, 2013 at 13:19

1 Answer 1

1

Just setting the action to point to the php file, and assigning the field names to variables in the php seemed to work:

In HTML:

<td>
  <form id="buy_prop" action="http://****_data.php" method="post">How much are you willing to spend?
</td>
<td>
    <input type="text" name="max_price" id="max_price">
</td>

In PHP

$max_price = $_POST["max_price"];    
$loan_fraction = $_POST["loan_fraction"];
etc etc
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.