PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
********************************
result in browser:
DVD-RPMK ----> 42
DVD-MATR ----> 40
DVD-UNSG ----> 30
DVD-UNSG2 ----> 30
DVD-FDBL ----> 24600
DVD-DHWV ----> 32800
DVD-LTWP ----> 29000
DVD-SPEED ----> 32000
DVD-SPEED2 ----> 3500
And when i delete this:
arsort($m);
But result in browser is like above!
Why arsort do not sort my array?
The problem lies in the nested while statements.
You are grabbing all the information associated with a single products_id number and processing that and then going back and doing the same thing again, for however many times. Each time it is printing the results before collecting a full array of all values.
Try moving the '}' last curly brace directly above the arsort($m); statement and see what the results are.
I test many format for above script. but can not solve problem.
please help me.
if we want capture data from database we must use array and array in above script model can not sort.
please help me how i can sort captured data?
for help me; can you write any script for sort above data? or can you debug my script?
thanks
I have good feeling you need a basic programming structures course/manual. This way you will learn how to iterate through a sorted file/resultset with different levels.. It will also allow you to write code that does all this with only 1 query.
$current_category = '';
$rs = mysql_query(...);
while ($row = mysql_fetch_assoc($rs))
{
if ($curent_category != $row['category'])
{
// a new category has started...
}
// do something with the product row
$current_category = $row['category'];
}