adam1972 Posted February 9, 2009 Report Share Posted February 9, 2009 (edited) I've mixed in some of Stefan's code to create a query: include ("Homes.Conn.php");include ("Tables_Includes.php"); $query = "SELECT * FROM 20mileradius WHERE $my_column LIKE '$my_query'"; $result = mysql_query($query); $my_rows; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $my_rows = $my_rows . "Name : {$row['City']} "."id : {$row['Beds']} "; } ?> and then echoeing them into a table like Stefan suggested.... What I'm wanting to do is create a query where the user can dynamically select what columns from the query results will be displayed on a table (there are currently 49 colums of data and bound to increase). I've looked into changing the query into using a variable from a list instead of the "SELECT *" I'm currently using, but I don't know how to pass the data checked off on a multiple select list on the query form( via an array? using _post) to the search results page. I've also played with creating check boxes on the query form (for all 49 + columns) and then creating variables for each checkbox... and then trying to use if statements while creating a table to control which gets echoe'd to the screen.... I've run into a brick wall.. my head hurts..... Does anyone have any good suggestions???????? Please? What and how would be the easiest way to let the user control the columns that get placed onto the query results table instead of just spitting out every column? Edited February 9, 2009 by adam1972 Quote Link to comment Share on other sites More sharing options...
jbwebdesign Posted February 15, 2009 Report Share Posted February 15, 2009 i'm not sure I understand what you mean but it seems like your trying to make a content management system..... why don't you just create a page with check boxes and give each check box a name..... for ex:: //define the vars for your check boxes $ch1 = $_POST['ch1']; check box 1 and then you use the variable $ch1 to your advantage for example if($ch1!="checked"){ //create a var that will be equal to ch1 within your query for example $check1 = "City"; } so now what happens is that when you decide to create your query you can include the variable $check1 which also equals City which is one of your columns inside your database. I'm not sure if this will help or not but I hope it does Quote Link to comment Share on other sites More sharing options...
adam1972 Posted February 15, 2009 Author Report Share Posted February 15, 2009 Thanks for the help jbwebdesign, I tried that route, I found that I actually need an array since I want to use the reults as avariable with the "SELECT" command in a query. I started a new a new thread to help me with converting the array into a string without the extra trailing comma I keep getting (removing the last character deletes ALL commas). If you have any ideas on a different dirction other than this I would sincerely and greatly appreciate the help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.