stualk Posted September 11, 2007 Share Posted September 11, 2007 Is it possible to display rows in order of a value within the rows? I need to do this without saying 'order by' in the 'select from' statement. The reason is because i'm using values from my select from statement to work out totals. Once i've worked out the totals i'm displaying the rows as per the code below. This works fine but I want to display the row containing the smallest $TOTAL_REDUCED value first, with the next highest next, and so on. Basically, what other ways of ordering rows are there in php? echo(" <tr height='50'> <td bgcolor='#FFCC66' width='25%'><strong><font size='2' face='Trebuchet MS'><a href='page.php?Step=StepTwo&&company_name=$company_name&&supplier_name=$supplier_name&&customer_id=$customer_id'>$supplier_name</a></font></strong></td> <td align='center' bgcolor='#FFCC66' width='25%'><a href='page.php?Step=StepTwo&&company_name=$company_name&&supplier_name=$supplier_name&&customer_id=$customer_id'><img border='1' src='images/logos/$logo'></a></td> <td align='right' bgcolor='#FFCC99' width='25%'><font size='2' face='Trebuchet MS'><strong> £$TOTAL_REDUCED</strong></font></td> <td align='right' bgcolor='#FFCC99' width='25%'><font size='2' face='Trebuchet MS'><strong>$offer_number $monthtext $offer_year</strong></font></td> </tr> "); Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 Put them in an array where the key is the $TOTAL_REDUCED, and sort them. Quote Link to comment Share on other sites More sharing options...
stualk Posted September 11, 2007 Author Share Posted September 11, 2007 I had a feeling someone would suggest that! I've never been one for using arrays, because I don't know how to use them mainly!! Is there no other way? Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 11, 2007 Share Posted September 11, 2007 Uhm, arrays are a very useful thing. You didn't know any PHP when you started but obviously you learned some. Why avoid using something just because you don't know how. Arrays are important and you'll need them eventually. Go read a PHP book. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.