spooke2k Posted June 11, 2007 Share Posted June 11, 2007 idea is to do a check see if a button beens clicked if it has then do the required querywhich works fine except for fact i am using pagenation as well and the query on a re run thinks its first time its been run and runs default query which works by a php self. i just want to check if the radio button is clicked remeber it if it has and then re run same query and also check if its changed radio button if has do that query instead but im getting myself confussed there must be a better way than what im doing it or trying to do it tbe. either way dont work and i need to remeber it and check if the radio button is same as last time. thanks in advance i know code has gone spagetti so opologies $searchfield = $_POST[textfield]; if ($searchfield == "Search Criteria") { $searchfield =""; } if ($searchfield <> "") { $query = "select * from pressimagelink where details like '%".$searchfield."%' order by productcode asc LIMIT $offset,$rowsPerPage"; $query1 = "SELECT count(*) as total FROM pressimagelink where details like '%".$searchfield."%'"; $_SESSION['query'] = $query; $_SESSION['query1'] = $query1; }else{ $oldinfo = $_POST['group1']; if ($oldinfo == "") { $cat = "1"; }else{ $cat = ($_POST['group1']); } if ($_SESSION['query']=='') { $query = "select * from pressimagelink where Cat = '".$cat."' order by productcode asc LIMIT $offset, $rowsPerPage"; $query1 = "SELECT count(*) as total FROM pressimagelink where Cat = '".$cat."'"; }else{ $query = $_SESSION['query']; $query1= $_SESSION['query1']; } } Link to comment https://forums.phpfreaks.com/topic/55128-solved-cant-make-it-remeber/ Share on other sites More sharing options...
Psycho Posted June 11, 2007 Share Posted June 11, 2007 You don't state which field is the radio button, so I'm not going to read through the code and try to decipher. But, you could use one of three methods to remember the radio button: session variables, cookies, or on the query string (i.e. $_GET). i would suggest using session data or the query string. Here is an example of how you could do it: <?php if (isset($_POST['radioField']) && $_POST['radiofield']=="thevalue") { //set variable switch $radio_option = true; $_SESSION['radioField'] = true; } else if($_SESSION['radioField'] == true) { $radio_option = true; } else { $radio_option = false; } if ($radio_option == true) { //Do query for the checked option } esle { //Do the default query } ?> Link to comment https://forums.phpfreaks.com/topic/55128-solved-cant-make-it-remeber/#findComment-272533 Share on other sites More sharing options...
spooke2k Posted June 11, 2007 Author Share Posted June 11, 2007 thanks for demo if (isset($_POST['group1']) && $_POST['group1']=="wildlife") { //set variable switch $radio_option = true; $_SESSION['radioField'] = true; } else if($_SESSION['radioField'] == true) { $radio_option = true; } else { $radio_option = false; } if ($radio_option == true) { $query = $_SESSION['query'] ; $query1 = $_SESSION['query1']; } else { $query = "select * from pressimagelink where Cat = '".$cat."' order by productcode asc LIMIT $offset, $rowsPerPage"; $query1 = "SELECT count(*) as total FROM pressimagelink where Cat = '".$cat."'"; $_SESSION['query'] = $query; $_SESSION['query1'] = $query1; } } thanks again and sorry to be pain. Link to comment https://forums.phpfreaks.com/topic/55128-solved-cant-make-it-remeber/#findComment-272558 Share on other sites More sharing options...
Psycho Posted June 11, 2007 Share Posted June 11, 2007 You're not a pain. If this solves your problem then please mark the thread "solved" Link to comment https://forums.phpfreaks.com/topic/55128-solved-cant-make-it-remeber/#findComment-272567 Share on other sites More sharing options...
spooke2k Posted June 11, 2007 Author Share Posted June 11, 2007 it doesnt seem to work but as i showed i think its something to do with my declarations of how i assign the querys i may be wrong im from a client side programming and server side seems to me very different. but alas as i showed it doesnt seem to work there is 6 radio buttons all named group1 thanks again Link to comment https://forums.phpfreaks.com/topic/55128-solved-cant-make-it-remeber/#findComment-272579 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.