You are here: Ordering inserted database values « PHP Programming Language « IT news, forums, messages
Ordering inserted database values

Posted by Frankie on 11/27/39 11:56

Hi,

I need to add shirt size info for new T-shirts into a mysql database in this
order: S, M, L, XL, creating the following table:

itemNumber size inStock
1000 S Y
1000 M Y
1000 L N
1000 XL Y etc...

Now, when I read the data back out, it'll be presented in logical
order. My queries are in sequential order by size, as follows:

if ($_POST['radioSmall'])
{
$size = "S";
$Squery = sprintf("INSERT INTO inStockApparel (itemNumber, size, inStock)
VALUES ('%s', '%s', '%s')",
$_POST['hfItemNumber'],
$size,
$_POST['radioSmall']);
$Sresult = mysql_query($Squery) or die(mysql_error());
}

if ($_POST['radioMedium'])
{
$size = "M";
$Mquery = sprintf("INSERT INTO inStockApparel (itemNumber, size, inStock)
VALUES ('%s', '%s', '%s')",
$_POST['hfItemNumber'],
$size,
$_POST['radioMedium']);
$Mresult = mysql_query($Mquery) or die(mysql_error());
}

etc....

But this results in random entries by size.

Is there a way to order these entries? If not, how would I use usort() to
get the order I want?

Frank H.
Austin, TX

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация