Page 1 of 1

Sorting fields into a table

Posted: Tue Jun 18, 2002 4:39 pm
by massiveone
:?:
The problem is as follows if anyone could help that would be greatly appreciated as i am still in the learning process and love php.

The problem consits of a table in a database that has the following layout

Sample Data

item size description stock
303l L large shirt 8
303s S large shirt 3

There are several items needless to say with variations in size but similar base item fields i want to be able to drop it in a nice table something like

item description xxs xs s m l xl xxl xxl
303 blah 3 3 3 4 8 6 5 5

Any ideas ?

Thanks

Posted: Tue Jun 18, 2002 9:16 pm
by kaizix
well, just call the data out using a select query (if it's mysql) and order it...

Code: Select all

$result = mysql_query("SELECT stock, size FROM tablename WHERE item LIKE '303?' ORDER BY size");
and it'll sort the results by the size in ascending order.. l, m, s, xl, xxl, xxxl, xs, xxs and then you can put the results in an array.

Code: Select all

$stockї"small"] = mysql_result($result, 2, "stock");
and so on 2 being the row number as the order goes. 0 being large, 7 being xxs. hope it works out...