Form sonucu birden fazla kombinasyon, php kodu kısaltmak için nasıl

0 Cevap

I have a php page that contains a form with 7 drop down boxes. The problem is that the 0 to 6 boxes may be unselected.

Her kombinasyon için case ile switch yapmak için bir sürü iş olurdu.

I başka hangi yöntemi kullanabilirim?

thanks, Sebastian

EDIT

Her kombinasyon için i açılan kutuları sadece seçili öğeleri içeren farklı sorguları yapmak zorunda.

Ör. Kullanıcı 7'den 3 seçerse, sorgu 3 koşulları geçmek zorundadır.

EDIT2 I don't know what the values of the drop-boxes are. Because they are built up using an mysql query in a while statement

SOLUTION

I've found a solution that should work. I haven't tested it yet. First of all i want to check if what is selected in the drop-boxes. `If($_POST[telefon]="empty"){$tel=""}

else {$ tel = "WHERE telefon = '"} `

after this i can concatenate the $tel string with the $_POST['telefon'] string. $query_tel=$tel.$_POST['telefon']." ' ";

Final sorgu dizesi bu $query="SELECT * table ".$query_telefon." ,".$query_ziua....(and so on) gibi görünecektir

Tabii ki ben çok eksik virgül, kesme ve için, neden olur sorgusu ile çok dikkatli olmak zorunda. Ama bu basit yolu sanırım.

0 Cevap