Re: RE: [newbie] drop down boxes

From: Date: Mon, 07 Apr 2003 12:52:39 +0000
Subject: Re: RE: [newbie] drop down boxes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-142811@lists.php.net to get a copy of this message
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:
can 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_by
FROM 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 Bob
From: 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:
I have created a dynamic table within my form. Above the table I want to insert a filter to order by:<the column
names>
Here is the static list: <select name="select4">
            <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 (a
variable?)and how
can I place that in such a way to ORDER BY <$filter_selected> 3. also simple snippets of code always is appreciated (No one
wants to
reinvent the wheel) :)
I' 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?
            <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
_________________________________________________________________ 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
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________ On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/mobile


« previous php.general (#142811) next »