1

I need to select multiple id's from my database example:

<input id=1 type="text" name="iDEAL" value=0 size=3>
<input id=2 type="text" name="PayPal" value=0 size=3>

I need to get the id from the database and still have the value from the input so now i have

$ideal = $_POST['iDEAL'];
$paypal = $_POST['PayPal'];

I was thinking i need some mysql query like the following:

$query = "SELECT bet_id FROM betalingsmethode WHERE  bet_id = ". $_POST['id'] . ""

From this point on I am stuck I can't think of a way to make this happen 10 times including formulas. I thought of a switch but then realised it stops after the first hit so that won't be an option.

I hope you guys have a solution.

E//

my database has the following structure

Betaalmethodes
 bet_id
 bet_naam

bundels
 bundels_id
 psp_id
 etc

tarieven
 id
 bet_id
 etc

I need to know the bet_id so i can tell php which bundle it needs to use for the formula same goes for 'tarieven' where i'll need the correct bundel_id.

3
  • Add your DB structure aswell, and your result and expected result Commented Nov 25, 2014 at 12:42
  • to prevent injection note that dont use $_POST['id'] directly in your query ! Commented Nov 25, 2014 at 12:43
  • 2
    Couldn't get a clear view from your question...Please elaborate bit more. Commented Nov 25, 2014 at 12:45

1 Answer 1

4
SELECT bet_id FROM betalingsmethode WHERE  bet_id in (list of all the ids)

IN is basically used as OR boolean operation, for example if you want to get rows having ids 1, 2 and 3. you can get them like

SELECT * from table_name where id in (1,2,3)

This will bring the rows having the id value as 1 or 2 or 3

Don't write inline queries even though you are using integer but still they are in secure.

Use mysql escape string function (google it) to clean them to avoid sql injection.

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.