Radio Button loop and query Help!!

Codes here !

Moderators: macek, egami, gesf

Matthew
New php-forum User
New php-forum User
Posts: 4
Joined: Thu Sep 29, 2011 9:16 am

Radio Button loop and query Help!!

Postby Matthew » Tue Aug 14, 2012 8:43 pm

Hello everyone,
I have dynamically created a series of radio buttons, with "Options" populated from mysql:

e.g.

"Option 1"
radio button 1 (OK)
radio button 2 (Maybe)
radio button 3 (Eliminate)

"Option 2"
radio button 1 (OK)
radio button 2 (Maybe)
radio button 3 (Eliminate)

Etc...

I have created a javascript loop (to loop through the form)...
I have also created a script and table to display the results dynamically..
However, I am having trouble querying the sql database to display the proper results..

HERE'S WHAT I NEED:

When radio button 1 is selected, I need the query to grab the selected "Option" to be displayed/printed.

When radio button 2 is selected, I need the query to grab the selected "option" and isolate it to be displayed/printed in a separate area(of the results page)

But when radio 3 is selected, I need the query to not grab this "option".. This "option" should be hidden from the user on the results page!

Im sure there must be a million ways to do this, but I cant find any articles that seem to help.. or maybe Im looking in the wrong place??! Please Help I would greatly appreciate it!!

Sorry if this seems confusing and Thanks in advanced!!!

Matthew
New php-forum User
New php-forum User
Posts: 4
Joined: Thu Sep 29, 2011 9:16 am

Re: Radio Button loop and query Help!!

Postby Matthew » Wed Aug 15, 2012 6:00 am

P.S. I can also add a snippet of code if it helps..!!

Code: Select all


$filterQuery = "SELECT *
      FROM table_2
      INNER JOIN table_1 ON table_2.Option_Id=table_1.Option_Id where ";
      
      $list = split($filterList,",");
      
      $first = false;
      
      foreach( $list as $filter ) {
         if( $first ) { $filterQuery .= " WHERE AND ";  }
      
         $filterQuery .= "table_1.Option_Category <> '" . $filter . "' AND table_1.Option_Type <> '" . $filter . "'";
         $first = true;
      }
      
      $filterQuery .= ";";


      $filterResults= mysql_query($filterQuery);


      $filter_row= mysql_fetch_assoc($filterResults);



Im joining two tables on the same column and wish t eliminate the option category and or type IF third radio button is selected..


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest