|
|
|
|
![]() ![]() |
Sep 5 2005, 08:57 PM
Post
#1
|
|
|
Klassified Group: Members Posts: 156 Joined: 7-June 05 From: Klass-World Member No.: 5,936 |
I have a form written in html with the input box labeled:
AttackBonus I have a query: SQL $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://army.klass-world.org/farm/index.htm |
|
|
|
Sep 5 2005, 10:54 PM
Post
#2
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 11 Joined: 10-August 05 Member No.: 7,739 |
QUOTE(Klass @ Sep 5 2005, 10:57 PM) 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://army.klass-world.org/farm/index.htm Klass, I am not sure but I think you refer to the file http://army.klass-world.org/farm/AoDFarm/attack.html. 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. |
|
|
|
Sep 6 2005, 02:03 AM
Post
#3
|
|
|
Absolute Newbie Group: Admin Posts: 888 Joined: 20-February 05 From: Indianapolis, Indiana, USA (Midwest) Member No.: 2,714 |
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 |
|
|
|
Sep 6 2005, 05:20 AM
Post
#4
|
|
|
Techno-Necromancer Group: Members Posts: 1,018 Joined: 13-January 05 From: The Net Member No.: 2,127 |
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 |
|
|
|
Sep 6 2005, 02:00 PM
Post
#5
|
|
|
Klassified Group: Members Posts: 156 Joined: 7-June 05 From: Klass-World Member No.: 5,936 |
wow,
for some reason there was 2 queries in my search page so the one I was working with was being over ridden with the other one. thnx for your help. |
|
|
|
Sep 6 2005, 10:51 PM
Post
#6
|
|
|
Klassified Group: Members Posts: 156 Joined: 7-June 05 From: Klass-World Member No.: 5,936 |
trying to add another query:
SQL 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 query to 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 1000 not sure how I do the second part of the query. |
|
|
|
Sep 7 2005, 03:50 AM
Post
#7
|
|
|
Techno-Necromancer Group: Members Posts: 1,018 Joined: 13-January 05 From: The Net Member No.: 2,127 |
QUOTE 10 times +/- by 1000 Not quite sure what that means, so I'm not sure how to help, can you describe that using words?~Viz |
|
|
|
Sep 7 2005, 12:40 PM
Post
#8
|
|
|
Klassified Group: Members Posts: 156 Joined: 7-June 05 From: Klass-World Member No.: 5,936 |
in the db there is different entries for Army_Size.
say 9000 875 209 450 etc. I need the query to do a calculation based on 1000 so 10 times more than 1000 and 10 times less than 1000 1000 would be my army size so i want to know who is in my 10 times attacking range for the first part of the query i have defense bonus in the db 56000 34000 309300 etc so by doing defens_bonus <= 91000 it should pull all the rows less than or equal to 91000 hope this helps |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 8th October 2008 - 05:36 AM |