Using Multiple Selection Array In Table To Order Data - Using multiple selection array in table to order data

free web hosting
Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Using Multiple Selection Array In Table To Order Data - Using multiple selection array in table to order data

eskimmer
have a form that has a multiple select choice, like this:
CODE
<form method="post" action="display.php"

<select multiple name="selectsort[]">
<option value="code">Code</option>
<option value="amount">Amount</option>
<option value="dateammended">Date Ammended</option>
<option value="expreviewdate">Expiration/Review Date</option>
<option value="effectivedate">Effective Date</option>
<option value="expired">Expired</option>
<option value="team">Issuing Team</option>
<option value="originate">OSL Originate</option>
</select>
</form>


The display.php file runs a query that sorts the results based on the selection (sometimes multiple) made in the form. The display.php file looks something like this:
CODE
$selectsort = $_POST['selectsort'];

if( isset( $_POST['selectsort'] )) {
$query = "SELECT * FROM contracts ORDER BY '{$_POST['selectsort']}' DESC";

}

$result = mysql_query($query);


I then echo the information in a table. I get results, but it doesn't pay attention to multiple selections. It only orders by the last selection made.

I can echo out the various selections and can see that the select part is working.
CODE
echo "$selectsort[0] , $selectsort[1] , $selectsort[2], ........"

How can use the selectsort[] array to order by the multiple selections?

Notice from Plenoptic:
ALL code posted must be put into [ CODE ] tags. Please review the Trap17 ReadMe for more rules and guidelines as to not receive warnings.

 

 

 


Reply

leiaah
Try this one. The while statement continually queries in the database while there are query results then prints the results in the screen using echo.

CODE
if( isset( $_POST['selectsort'] )) {
    $query = "SELECT * FROM contracts ORDER BY '{$_POST['selectsort']}' DESC";

    $result = mysql_query($query);

    while($result_rows = mysql_fetch_row($result)){
        echo 'field 1 value: '.$result_rows[0];
        echo 'field 2 value: '.$result_rows[1];
        echo 'field 3 value: '.$result_rows[2];
    }
}

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : multiple selection array data multiple selection array data

  1. Evilboard (forum Software) - Multiple Categorys - Don't Work :( - I am creating a forum and i can't fix more then 1 category. (6)
    I am at the moment trying to program my own forum, but i need more then a single category, here is
    my source: CODE function cat () { include("functions/functions.php");
    echo '<table width="100%"  border="0" cellspacing="0">
    <tr> <td class="eb_top" colspan="3" style="border-bottom-width:
    0; height: 30px; font-size: 12px;"> <b>Forum</b></td>
    </tr>';      global $catid;   $db = new db;   $db->connec...
  2. Remove A Value From A Php Array Based On Its Value - (5)
  3. How Good Is This Data Cleaning Function? - (2)
    Hi all, this is my first function and as part of a script and i just want to know a couple of
    things. here is the code for the function: CODE <? function
    clean($dirty_string) { $muddy_string = stripslashes($dirty_string);
    $murky_string = strip_tags($muddy_string); $clean_string =
    htmlentities($murky_string);      }; ?> So the first thing is how secure is
    it? the script this will be used in connects to a database and sends an email so it needs to stop
    SQL injections and any email ab...
  4. Php + Mysql Question! - While inserting data into MySQL, how can I know if the data I'm in (4)
    Basically, I want to know if the Data I'm inserting through a Form is already there or not. Sort
    of a Username registration page. I have this, but it doesn't appear to work... CODE
    $result = mysql_query("SELECT * FROM users WHERE
    username='$username'"); if($result == 1)     {     echo
    '<h1>ERROR!</h1>The username you have chosen already exists!';     }
    ...
  5. Php Email Validation - A PHP data validation class with many functions (1)
    I've been reading through my old php book (PHP 4.1) and came across this data validation class.
    It can check a number of things ranging from telephone numbers , credit card number formats, email
    address and some others. I checked out some of the methods although I didnt expect it to work 100%
    because I've found source code errors thoughout the book and CD. I tested out a few of the
    methods to check and some of them did return expected results but some didnt either so the data
    validation class was not perfect and it didnt really bother me. The cool thing I found...
  6. Getting An Array Value Of A Dynamic Variable - (9)
    Ok i can't believe I need help in php but I can't figure this out... If i have an array,
    lets say called test, how do i get a certain value from that array when referencing it dynamically
    by either a string or another variable? Example: CODE $test=array(1,2,5);
    $name="test"; //Doesn't work: echo $$name[0]; /Doesn't
    work: echo ${$name}[0]; ...
  7. Multiple Drop Down Lists ? - Multiple drop down lists to take user to new page (4)
    Hi everyone I was wondering if anyone could help. I want to create a page with multiple drop down
    lists and depending what the user selects decides the page they will be taken to. Sorry i havent
    explained this too well. Here is an example of what i want (link below) the user is also emailed a
    copy http://www.dermalogica.com/SpeedMappingOnl...US®ion=B I have searched the web and come
    close but nothing does it right I would be extremely greatful if anyone could help! Thanks ...
  8. Selection Problem - (4)
    I need help on a join, I think I have it mostly done, but I know my syntax isn't right. First
    off, to give you an idea, I have two tables, plus my session variables. I'm first selecting from
    the table: user_resources where the user_id = that of the $_SESSION's, and in
    user_resources, there are three fields, user_id, resource_id, and amount, and I wish to print all of
    this. But the hitch to it is, resource_id is an integer. In another table called resources, are the
    fields id and name. The resource_id = resources.id, and I want to print the name associat...
  9. Reading Files From Directory To Array, And Using $_get To Get Them - Simple way to manage lot's of files (2)
    Some user posted a similar problem i had when i tried to figure out how to update content on my
    website in less work as possible. This is just part of the "big" plan i have for my site but it can
    be helpfull to you guys if you like FlatFile. I hope that mod's don't mind me posting the
    same code here and on their forums, couse if they do i'll delete it from their forums
    /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> So
    here's the situation. Let's say you have a folder called 'myfilesdirectory' on your
    s...
  10. More Dynamic ?id=browsing With Php (associative Array) - Just create array and watch php code do the rest (1)
    The thing that has been bugging me for a while was that switch statement that we use to create ID
    browsing (some use If-Ifelse but results are the same for both). I wanted to figure out a way to use
    more dynamic switch statement so that i only need to update my links array in order to create links
    for template. With use of foreach, array_keys, and in_array functions finally i managed to do so.
    Also i'm planing on changing foreach with array_walk but i'll do that later. Now for the
    code.. First we create an associative array something like this CODE $gl...
  11. What Does This Do? - $ban = ($data->login) ? $lban : $iban; (4)
    I'm correcting a 'few' php-files for a friend, but I got this line of code: CODE
    $ban = ($data->login) ? $lban : $iban; and I don't know
    what it does xD Could someone please explain me what this line does? Thanks...
  12. Problems With Data Formatting - (2)
    I have a MySQL database which stores articles. A sample article would look like this: CODE This
    is a body. This is a body.This is a body.This is a body.This is a body.This is a body.This is a
    body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This
    is a body.This is a body.This is a body.This is a body. This is a body.This is a body.This is a
    body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This
    is a body.This is a body.This is a body.This is a body.This is a body. That'...
  13. Putting Data Of 2 Pages In Mysql At Once - (1)
    suppose i have a page, page.php?part=1 there i have some text fields. user will give input, but
    after taking input, it will not put the data in mysql .. but it will take to the next step..
    page.php?part=2 (if any field is left blank, it will not go to next page.. ) . and there also some
    fields.. after the user has filled that form also, then it will insert all data (from part1 and
    part 2) in mysql. i want to ask, how i can collect data from 2 pages and put in mysql at once....
  14. Sql Selection Issues - (1)
    CODE CREATE TABLE pbm_album (     id TINYINT(8) AUTO_INCREMENT,     parent_id
    TINYINT(8)     pbm_name VARCHAR(100),     pbm_desc VARCHAR(150),
        pbm_order TINYINT(8),     pbm_image varchar(100),     pbm_cat_id
    TINYINT(8),     pbm_create_date int NOT NULL,     FOREIGN KEY pbm_cat_id REFERENCES
    pbm_catalog(id),     PRIMARY KEY(id) ) CREATE TABLE pbm_photo (     id
    TINYINT(8) AUTO_INCREMENT,     pbm_name varchar(20) NOT NULL,     pbm_title
    varchar(60) NULL,   ...
  15. Loading Mysql Data Into A Table - (10)
    Hey i have a little problem with my php script. i dont really know how to make it work ^^; I want to
    have this exact table: ' I made mysql table that has one column for id(auto-increment,
    primary key), and then it has row and collumn and text. row means which row in the html table and
    collumn wich collum. (obviously /tongue.gif" style="vertical-align:middle" emoid=":P" border="0"
    alt="tongue.gif" />) here is the mysql table screenshoted from phpMyAdmin: r means row and c
    collumn /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue...
  16. Spliting An Array - (4)
    I got this excercise from school, im trying to understand it but im unable..can someone help me ?its
    very small problem but im not getting the point. ------------------ Create a string:
    $wholestring = “splitwholestring”; And split it to array using for loop. So that you have a
    array containing all the letters of the string: array == s, array == p, etc. Display results.
    (hint: strlen(), substr() - functions are useful) ------------------...
  17. Same 1 Registeration Data For Different Purposes - (4)
    I want to install 4 scripts on my website .. 1- Gallery 2-Classfied Ads 3-Game Cheats Script (A
    simple script where ppl can register and then submit the cheats) 4-Php Nuke The problem is that all
    of 4 scripts needs registeration of members (use 4 different databases).... I want that all the
    member which is registered at one place can login at all of the services..i mean , one registeration
    form , that can work for all.. how i can do it ? Please tell in details..thanks....
  18. Converting Characters In A Variable To Individual Values In An Array - turning variables into arrays (2)
    Say I have a variable such as $nav_item and it had to contents Home . IE: CODE
    $nav_item = 'Home'; How would I make so that $nav_item was an array and
    had the following contents? CODE $nav_item = array ('h', 'o',
    'm', 'e'); With the case changing (ie H would become h and U
    would become u ) EDIT: Okay found out that I could change the case with
    array_change_key_case ($nav_item, CASE_LOWER); ...
  19. Multiple Options? - (3)
    Okay so what Im trying to figure out is how I would go about giving the people to uh, well for
    examplkes sake it would be like "how many cats do you have" then theyd fill in a number, submit and
    the next page would print out boxes for as many cats they have that will be too fill in a color of
    the cat, so basically something like that, where it will only give them so many fields based on how
    many they said they have, and then their final "reciept" will only print out stuff for as many as
    they filled itn ...
  20. Finding Data In Meta Tags - using php to search Meta Tags for data (0)
    In the Head portion of an Html file, there are usually several Meta Tags that contain data about
    various things, like the tag for keywords, an Author's name or maybe a description field. Here
    are two example Meta tags: HTML meta name =" Keywords " content=" keyword1, keyword2 " />
    meta name =" Description " content=" A Description of the file's content is here " /> So,
    what I have a question about concerns checking a file to see what information is included in these
    tags and using that information as variables or content in the output of the page...
  21. Listing From Table Row Data - Listing all members (5)
    Hello, it's been a while since i've been active in the PHP Board ( i used to be really
    active in here ), not only to help others but also to request help ( people knowing those requests,
    dont share your bad experience with my requests /tongue.gif' border='0'
    style='vertical-align:middle' alt='tongue.gif' /> ) Anyway, i am requesting help on a listing of
    members, i totally forgot about how to fetch the rows from a table and display each row, i thought
    it was: CODE $result=mysql_query("SELECT * FROM $usertable ORDER BY id
    DESC") or...
  22. Remove Objects From Array With Unset - (2)
    Have been trying to solve this for a long time now, so I thought I´d give you guys a chance to break
    it! I want to remove an object from an array that I store in a Session object. I´ve written a
    function that takes an array and an id as parameters. Checks if one of the objects has the id I want
    to remove and then it´s supposed to remove it. Quite simple, that´s why I cant see why it doesnt
    work! Here´s the code: CODE function Remove_prod($id2,$AL) {
    print_r($AL); foreach ($AL as $prod) if($prod-...
  23. How Handle Sending Back Multiple Checkboxes - (1)
    I know how to send back the check-boxes, so that's not the issue. I have a form that contains a
    group of 5 check-boxes. The user could select none, one, all, or any combination in between.
    I'm working on form validation right now and am doing most of it server side. The validation is
    set so that if the user has to go back all their data is retained. I'm using case statements,
    which work wonderfully, but in this circumstance I don't know what would be the best method that
    allows for a multitude of combinations. I think there is a possibility of somethi...
  24. Help With Reading Files - Read and replace/insert data from form (5)
    Hi, Does anyone know how i can do this, or scripts that will work on Trap17's servers and will
    do the following: I have a .doc file form. Which i want to have filled in automactically, by HTML
    Form and emailed to my address, with the data filled in. Any ideas? I have heard many differing
    things, like XML, RTF, DOC, PDF... I have serched through many places and come up empty handed with
    anything that works. /sad.gif' border='0' style='vertical-align:middle' alt='sad.gif' /> ...
  25. Form To Pdf, With Email? - Wanting to Submitt Data to PDF (3)
    Hi all, This sounds like a good place to ask this, I have a form Click Here to View that when
    submitted will put the values into the PDF Here Is there a way in which to have the filled in
    form both viewed to the user? and also have it emailed to me as an attachment. Any code or help
    would be good... I get basics, but this stuff is hard to get to work and i can't get it to....
  26. Php Classes - Access the same class instance over multiple pages (1)
    Hey everyone. I am having some trouble accessing the same php class instance in more that one page.
    This is for my login script and what i need to do is be able to call the classes logout function
    from a separate page. What i have tried to do is create a new .php page and include the class file
    and then make a new class and call logout. This does not work because it does not log out the
    current user which is my problem. Can anyone help me fix this or know of another way to do it?
    Below is my class file CODE <?php     // member class     // handlers member logo...
  27. Php Sessions - Multiple users using the same login (2)
    Hi, I'm realtively new to PHP and I'm considering creating some login functionality.
    However I want a group of users to use the same loginname and password. They will be loggin infrom
    different machines. The users will know they are sharing the account. Can anyone give me an idea
    of what kind of effect this might have on my sessions? Will it create any odd hiccups or other
    strange things?...
  28. How To Redirct Post Data ? - (4)
    I have a form, from where the data is being posted to a php script. Now in the php script the script
    has to forward the data to another script with posted data. I know this can be done using header but
    i don't know how to keep the data posted with form in POST method. For example: The form
    below: Code: Now its posting data using POST method to 1.php...and now 1.php will
    redirect everything to another php script with the data and it should be in POST method ... How can
    i do this ? Thanks. ...
  29. Flash Games And Post Data - (0)
    i want to put a highscore section for a bunch of flash games on a website. i know that when most
    games are done the score is in the post data, which can be viewed if you have the firefox live http
    headers extension. but how would you insert the postdata from the flash games into the database?...



Looking for multiple, selection, array, table, order, data, multiple, selection, array, table, order, data

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for multiple, selection, array, table, order, data, multiple, selection, array, table, order, data

*MORE FROM TRAP17.COM*
Evilboard
(forum
Software) -
Multiple
Categorys -
Don't
Work :( I am
creating a
forum and i
can't
fix more
then 1
category.
Remove A
Value From A
Php Array
Based On Its
Value
How Good Is
This Data
Cleaning
Function?
Php + Mysql
Question!
; While
inserting
data into
MySQL, how
can I know
if the data
I'm in
Php Email
Validation A
PHP data
validation
class with
many
functions
Getting An
Array Value
Of A Dynamic
Variable
Multiple
Drop Down
Lists ?
Multiple
drop down
lists to
take user to
new page
Selection
Problem
Reading
Files From
Directory To
Array, And
Using
$_get
To Get Them
Simple way
to manage
lot's of
files
More Dynamic
?id=browsing
With Php
(associative
Array) Just
create array
and watch
php code do
the rest
What Does
This Do?
$ban =
($data-
>login) ?
$lban :
$iban;
Problems
With Data
Formatting
Putting Data
Of 2 Pages
In Mysql At
Once
Sql
Selection
Issues
Loading
Mysql Data
Into A Table
Spliting An
Array
Same 1
Registeratio
n Data For
Different
Purposes
Converting
Characters
In A
Variable To
Individual
Values In An
Array
turning
variables
into arrays
Multiple
Options?
Finding Data
In Meta Tags
using php to
search Meta
Tags for
data
Listing From
Table Row
Data Listing
all members
Remove
Objects From
Array With
Unset
How Handle
Sending Back
Multiple
Checkboxes
Help With
Reading
Files Read
and
replace/inse
rt data from
form
Form To Pdf,
With Email?
Wanting to
Submitt Data
to PDF
Php Classes
Access the
same class
instance
over
multiple
pages
Php Sessions
Multiple
users using
the same
login
How To
Redirct Post
Data ?
Flash Games
And Post
Data
advertisement



Using Multiple Selection Array In Table To Order Data - Using multiple selection array in table to order data



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE