Re: RE: [newbie] drop down boxes
| From: | fasta | Date: | Tue, 08 Apr 2003 07:25:38 +0000 |
| Subject: | Re: RE: [newbie] drop down boxes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142809@lists.php.net to get a copy of this message | ||
One hint...
get that session_start() off the script, and start using $_SESSION["varname"] = value, instead of session_register(), wich can cause random problems.
Did u manage to solve the sql query prob in the meanwhile? ;)
Andrea Fastame
Bobby Rahman wrote:
Firstly I want to say thanks to all that replied I finally got the drop down boxes working. Does anyone know (on the off chance) how to fix the size of rows. it seems when the query returns only 2 rows the html table is made very big with huge row borders and text...when many rows returned from db the html table rows looks much more normal(smaller). For any fellow newbie's who have this problem I have included a snippet of code at the bottom. <? session_start(); ....... <select name="severity"><option value="Severity">Severity</option> <option value="Crash">Crash</option> <option value="Major">Major</option> <option value="Minor">Minor</option> <option value="Review">Review</option> </select> <?if(!isset($severity)) { $_SESSION['querystring'] = "SELECT bugid, status, severity, assigned_to, summary, date_opened , estimated_completion, related_file, created_by FROM Bug"; } else { $_SESSION['querystring'] = "SELECT bugid, status, severity, assigned_to, summary, date_opened, estimated_completion, related_file, created_by FROM Bug WHERE severity ='$severity' LIMIT 40"; } ?> //then in file2.php session_start(); $db_result = mysql_query($_SESSION['querystring']) or die(mysql_error());From: fasta <afasta@libero.it> To: Bobby Rahman <bobby_rahman2002@hotmail.com>, PHP <php-general@lists.php.net> Subject: Re: [PHP] RE: [newbie] drop down boxes Date: Mon, 07 Apr 2003 14:52:39 +0200 How about: 1.First of all, put all your drop-downs in a single form. 2.<select name="severity" onchange="javascript:formSubmit()"> 3.Form submit just submits your form to the php page wich checks the request params sent by the drop-downs 4. upsaid php page rebuilds the sql query, building the order by adjusting to what you just submitted. It's a little different from the code following... Andrea Fastame Bobby Rahman wrote:I have created a dynamic table within my form. Above the table I want to insert a filter to order by:<thecan you further detail about the Javascript to connect the drop down to the table. Currently after a much appreciated suggestion I have made these changes below:<select name="severity"> <option>Severity</option> <option>Crash</option> <option>Major</option> <option>Minor</option> <option>Review</option> </select> <?$selects = array ('severity','crash','major','minor','review'); $select = strtolower($_POST['severity']); if (!in_array($select, $selects)){ $select = 'severity'; } $Severityquerystring = "SELECT bugid, status, severity, assigned_to, summary, date_opened, estimated_completion, related_file, created_byFROM Bug ORDER BY '$select' LIMIT 40"; ...........//a little further down if (isset($severity)) { $querystring = ($Severityquerystring); } else { $querystring= "SELECT * FROM bug"; } $db_result = mysql_query($querystring) or die(mysql_error()); Still doesnt seem to be connected....no errors but no changes occur either?From: andrea fastame <fastame@sysnet.it> To: Bobby Rahman <bobby_rahman2002@hotmail.com>, PHP <php-general@lists.php.net> Subject: Re: [PHP] RE: [newbie] drop down boxes Date: Mon, 07 Apr 2003 12:42:03 +0200 ehm... I think yer almost done, there... Just connect a javascript to each of those drop-downs wich reloads the page and builds a SQL query with the order by params you select with the drop downs themselves. Confused enuff? ;) Andrea Fastame Bobby Rahman wrote:Hiya I will try and be slightly clearer: I have a dynamic table in form (meaning) I display results from a mysql database table "bug" in the html form. Dynamic being that entering rows into the mysql table - the results are also updated in the html form automatically. But the stage im stuck on is that I want to filter the html table in certain ways. i.e If I want to see all the bugs assigned to me (bugs which have been stored in teh db with the value =assigned_to = "bob". I want to use a drop down box to select my name and for the table in the form to only display all the bug rows which are assigned_to me. The sort element is that I want to be able to sort the columns by an atrribute (in this case by the column names). By default the table is ordered by bugid currently but I want to be able to sort by other attributes in the bug table. e.g select sort_by <date_submitted> from the drop down box will result in all the bugs now being ordered by date_submitted. I have created the drop down boxes and the table but now need to understand how to code the logic to connect the drop down boxes to the table. At the moment when I select sort_by <date_submitted> nothing happens as im not sure how I can cause effect on the table. Hope this is clearer :) or have I confused people more Thanks BobFrom: JanetVal@aol.com To: bobby_rahman2002@hotmail.com Subject: Re: [PHP] RE: [newbie] drop down boxes Date: Sun, 6 Apr 2003 14:15:39 EDT In a message dated 4/6/2003 7:45:15 AM Pacific Daylight Time, bobby_rahman2002@hotmail.com writes:Here is the static list: <select name="select4">column names><option>Severity</option> <option>Crash</option> <option>Major</option> <option>Minor</option> <option>Review</option> </select>What I need suggestions on is: 1. recommended tutorials on lists and logic behind them. 2. How does the selected item in the list get stored (acan I place that in such a way to ORDER BY <$filter_selected> 3. also simple snippets of code always is appreciated (No onevariable?)and howreinvent the wheel) :)wants to_________________________________________________________________ Surf together with new Shared Browsing http://join.msn.com/?page=features/browse&pgmarket=en-gb&XAPID=74&DI=1059_________________________________________________________________ On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/mobile-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpI' don't know what you mean by "dynamic table within my form". Are you talking about making your list appear in alphabetical order? Obviously, if you wanted the above list to appear in alphabetical order, you would just change it around. Do you mean that your list is created using variables?_________________________________________________________________ Overloaded with spam? With MSN 8, you can filter it out http://join.msn.com/?page=features/junkmail&pgmarket=en-gb&XAPID=32&DI=1059<option>$fieldname1</option> <option>$fieldname2</option>If so, I would put the field names in an array, such as: $arrayoffields[0] = Severity $arrayoffields[0] = Minor etc. . If you get the fieldnames from a database table, you could use ORDER BY when you do your SELECT statement. Then they are in order in the array. Otherwise, you could just sort the array. Then, you could build your list like this: foreach( $arrayoffields as $value) { echo "<option> "; echo $value; echo "</option>"; } and they will be in order. In the script that processes this form, you will have an array $_POST that contains all the variables in your form. You can access the value for this list as $_POST['select4'] and do whatever you want with it. I don't understand what you mean by sort here. You only have one value after the form is submitted. That is, whichever value the user selected. Janet