Re: RE: [newbie] drop down boxes

From: Date: Mon, 07 Apr 2003 12:46:52 +0000
Subject: Re: RE: [newbie] drop down boxes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-142689@lists.php.net to get a copy of this message
On 07-Apr-2003 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. Suppose your select is name="sortby". When processing your post you do: if (empty($_POST['sortby']) ) // test set default $_POST['sortby']='bugid'; $qry="SELECT ... FROM ... WHERE ..."; $qry .=' ORDER BY' .$_POST['sortby']; if ($res = mysql_query($qry) { ... do the table ... Regards, -- Don Read dread@texas.net -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it.

« previous php.general (#142689) next »