Posted: Fri Sep 15, 2006 1:34 pm
You're welcome.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
I took that straight from your code. I only cleaned up redundancy and use of code that was duplicated one line up. I didn't really change anything.rami wrote:Note by the way the solved code by Everah is logically incorrect...
i have no complains for thatEverah wrote:I took that straight from your code. I only cleaned up redundancy and use of code that was duplicated one line up. I didn't really change anything.rami wrote:Note by the way the solved code by Everah is logically incorrect...
This is your problem. You do NOT need a seperate query for each case. You need to build a query from different parts. This was shown at the beginning of the thread.rami wrote:i tried switch but same thing i need query in each case so same thing....
can you show me howonion2k wrote:This is your problem. You do NOT need a seperate query for each case. You need to build a query from different parts. This was shown at the beginning of the thread.rami wrote:i tried switch but same thing i need query in each case so same thing....
Code: Select all
$radio_selected = $_POST['radio'];
$sql = "SELECT first_field, second_field, third_field FROM table_name ";
switch ($radio_selected) {
case 1:
$sql .= "WHERE id <= 10";
case 2:
$sql .= "WHERE id > 10";
default:
die('invalid radio button choice');
}
$sql .= " ORDER BY id";
$result_set = mysql_query($sql);A little off-topic, but you're actually wrong. Sort of. The data is coming from a user's browser .. you have no way to tell what they used to input that data. In 99.9% of cases it'll be your radio buttons, but if someone is trying to hack into your application that information could be anything. Don't assume that just because you only gave them a specific set of options that the incoming data will definitely be one of them. Always sanitise and validate any incoming form fields.rami wrote:by the way it is getting data from drop down not radio..just a info...