Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Getting Form Information To Database Query
Klass
post Sep 5 2005, 08:57 PM
Post #1


Klassified
Group Icon

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
Go to the top of the page
 
+Quote Post
calixt
post Sep 5 2005, 10:54 PM
Post #2


Newbie [ Level 2 ]
Group Icon

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.
Go to the top of the page
 
+Quote Post
vujsa
post Sep 6 2005, 02:03 AM
Post #3


Absolute Newbie
Group Icon

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
Go to the top of the page
 
+Quote Post
vizskywalker
post Sep 6 2005, 05:20 AM
Post #4


Techno-Necromancer
Group Icon

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
Go to the top of the page
 
+Quote Post
Klass
post Sep 6 2005, 02:00 PM
Post #5


Klassified
Group Icon

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.
Go to the top of the page
 
+Quote Post
Klass
post Sep 6 2005, 10:51 PM
Post #6


Klassified
Group Icon

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.
Go to the top of the page
 
+Quote Post
vizskywalker
post Sep 7 2005, 03:50 AM
Post #7


Techno-Necromancer
Group Icon

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
Go to the top of the page
 
+Quote Post
Klass
post Sep 7 2005, 12:40 PM
Post #8


Klassified
Group Icon

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
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. phpBB Database Transfer(10)
  2. Embedded Database(7)
  3. Need Advice On Creating Online Music Database(6)
  4. Mirror My MySQL Database To Another Mysql Server(4)
  5. The Best Database(48)
  6. Database Program With GUI(14)
  7. MySQL Output Database Question(18)
  8. What Is Maximum Capacity Of Astahost MySQL Database?(11)
  9. Is It A Good Practice To Store Image Or Other Binary Files Directly In A Mysql Database(4)
  10. Permission Problem With Mysql Database Creation(8)
  11. Need Info On Database Programming Courses(2)
  12. Database Programming In Vba 6.0(1)
  13. How Many Concurrent Users For Oracle Database?(1)
  14. Database Size?(10)
  15. My Sql Database Help?(3)
  1. Need Help In Database Auto_increment(9)
  2. Mysql Query Question(3)
  3. Connecting To A Remote Database(9)
  4. Database(1)
  5. Integrate Access Database Onto Intranet Site(5)
  6. Accessing Ms Access Database From A Centralized Location?(5)
  7. Mysql Database Management(1)
  8. Mysql Database Entry By Excel Sheets(2)
  9. Space Needed For Database(10)
  10. Database Access On Remote Server W/jsp(0)
  11. Some Useful Database Links.(7)
  12. Best Database(7)
  13. How To Understand A Database Schema(4)


 



- Lo-Fi Version Time is now: 8th October 2008 - 05:36 AM