Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

CFitz's Achievements


Newbie (1/14)



  1. The query runs fine both ways, only with the checkbox clicked it still doesn't filter. I believe the issue is that I am not getting anything into the variable $tresult from "$tresult = mysqli_fetch_assoc($t);" Have any ideas?
  2. Above the code I presented earlier: $where_y_s = $_SESSION['where']; Below the code I presented earlier: $where_n_s = str_replace(' ', '_', $where_y_s); The user provides the "where," but in this site's case, "where" could include spaces, which I replace with underscores below before running the variable through a query! I hope this helps the understanding of my problem!
  3. Sure! echo ' <form method="post" action="#"> <label id="exampleid"><input type="checkbox" name="checkbox_county" value="checkbox_county" '; if (isset($_POST['checkbox_county'])) { echo "checked=\"checked\" />Only $where_y_s."; } else { echo ">Only $where_y_s."; } echo ' </label> <input class="exampleclass" type="submit" value="Go" /> </form> Note: I defined the $where_y_s via a session variable above the form. Thanks!
  4. Thank you very much for the response and help! I'm sorry for the rather late reply, but I was just getting back to that particular problem in my site! This leads me to my next minor issue... I have incorporated a bit of that code as follows: $filter_on_own_id = isset($_POST['checkbox_county']) ? true : false; if ($filter_on_own_id) { $s = "SELECT county_id FROM counties WHERE county_name = '$where_n_s'"; $t = @mysqli_query ($mysqli, $s); $tresult = mysqli_fetch_assoc($t); $q = "SELECT title, description, image, x_id FROM x_representatives WHERE county_id = '$tresult' ORDER BY $order_by LIMIT $start, $display"; } else { $q = "SELECT title, description, image, x_id FROM x_representatives ORDER BY $order_by LIMIT $start, $display"; } $r = @mysqli_query ($mysqli, $q); I have a checkbox that lets the user filter the results down to only those that match his county_id (defined earlier). When a user clicks the checkbox and submits the form, the page simply returns the same list of query results as before. Do you think this is an html error or something to do with the php? I appreciate the help folks!
  5. I appreciate the responses. I see that it is unreasonable to ask for assistance with such a vague question, so I shall elaborate! I am currently running the following query (I sort the results via a pulldown menu): $q = "SELECT title, description, image, x_id FROM x_representatives ORDER BY $order_by LIMIT $start, $display"; $r = @mysqli_query ($mysqli, $q); Before navigating to this web page, users fill out a form that sets their own "x_id" to a certain value. I would like them to be able to hit a checkbox that allows them to see only results that match their "x_id" to those of the query. I was thinking along the lines of a prepared statement but am having trouble. I appreciate the help, and please let me know if I need to further explain. (HartleySan, thank you for the welcome, and if running multiple queries will have no noticeable effect on performance I may just go that route!)
  6. My brain must be dead, because while I read the book, I am having trouble devising a solution to this problem. I would like to include a button on a page of query results that allows users to filter the results to those that match only certain criteria. I realize that it's not a good idea to run a whole new query just for this filtering, so I have been trying to look for a solution, but to no avail. Any tips? I'm sorry for being vague, I'd just rather not give away too much about the site's structure. Thank you!
  • Create New...