PHP在str_pad之后按变量排序

I want to sort my table by variable that i made from sql data itself. So here the code

$sql="select * from schedule";
$query=mysql_query($sql);
while($data=mysql_fetch_array($query)){
$new_date=str_pad($data['date'], 10, '0', STR_PAD_LEFT);

is that possible if $sql="select * from schedule order by $new_date" ?

i've tried that code but it didn't worked. So i will really appreciate if you answer my question, sorry for my bad english.

"select * from schedule order by variable" Note variable is a column in schedule

This doesn't show what you're trying to accomplish. Sorting your table should occur in the query $sql, so for example... SELECT * FROM schedule ORDER BY colName would be a way to sort on colName.

You can use LPAD(str, len, padstr) to pad directly in your query:

ORDER BY LPAD(column, 10, 0)