Jump to content
xisto Community
Klass

Getting Form Information To Database Query

Recommended Posts

I have a form written in html with the input box labeled:
AttackBonus

I have a query:

$query = "Select * From i bf_farmlist Where '%".$AttackBonus."%' >= i bf_farmlist.Defense_Bonus Order By i bf_farmlist.Name Asc";



I have no idea how to get the form variable to the query, as the variable always changes.

Here is the form:
http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

I have a form written in html with the input box labeled:

AttackBonus

 

I have a query:

 

$query = "Select * From i bf_farmlist Where '%".$AttackBonus."%' >= i bf_farmlist.Defense_Bonus Order By i bf_farmlist.Name Asc";

 

I have no idea how to get the form variable to the query, as the variable always changes.

 

Here is the form:

http://forums.xisto.com/no_longer_exists/

<{POST_SNAPBACK}>


Klass,

I am not sure but I think you refer to the file

http://forums.xisto.com/no_longer_exists/.

IMHO in your query the part "$AttackBonus" should be replaced by "$_POST['AttackBonus]".

As far as I know, the attribute "enctype='multipart/form-data' " in your <form> tag is not necessary.

Share this post


Link to post
Share on other sites

Klass, I'm pretty bad with MySQL queries but here goes.

 

$query = "SELECT * FROM i bf_farmlist WHERE i bf_farmlist.Defense_Bonus <= '$_POST[AttackBonus]' ORDERED BY i bf_farmlist.Name Asc";

 

The field name comes first and is compared to the variable.

 

That should help a little. Like I said, I'm not very good at MySQL queries.

 

vujsa

Share this post


Link to post
Share on other sites

Since the form goes to a PHP script (where I imagine you perform the SQL query) it is really more of a php question than a database one. However, all you need to do is acces the PHP Post array. you can do this by using it as a variable: $_POST[key] where key is the name of the form element you wish to get a value for. All you have to do is an assignment statement to assign the POST variable to another variable, then simply use that variable inside your query statement. If that doesn't help, showing the code you use, would allow me to better serve your needs.

 

~Viz

Share this post


Link to post
Share on other sites

trying to add another query:

select * From farmlist Where farmlist.Defense_Bonus <= 91000 AND farmlist.Army_Size <> 1000 Order By farmlist.`Time` Desc

What I want is the first part of the queryto give me all Defense_Bonus less than or equal too 91000 which is defined by: <= &the second part of the query to give me Army_Size 10 times +/- by 1000not sure how I do the second part of the query.

Share this post


Link to post
Share on other sites

in the db there is different entries for Army_Size.say 9000875209450etc.I need the query to do a calculation based on 1000 so 10 times more than 1000 and 10 times less than 10001000 would be my army size so i want to know who is in my 10 times attacking rangefor the first part of the query i have defense bonus in the db5600034000309300etcso by doing defens_bonus <= 91000 it should pull all the rows less than or equal to 91000hope this helps

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.