Hi Everybody,
I am using the following function to get the data from mysql database. i have entered appnum field as text filed in the database which has leading zeroes to this field like if number is 0001, 0010, 0101 (four figures). Now i got problem while sorting them as it is a string value and its giving error when im trying to convert it into integer using (int)$appnum its trimming the leading zeros. I want this field as the string field and want the leading zeroes as it is. please tell me. how i can sort it in ascending or descening orders (numeric) thanx.
I am using the following function to get the data from mysql database. i have entered appnum field as text filed in the database which has leading zeroes to this field like if number is 0001, 0010, 0101 (four figures). Now i got problem while sorting them as it is a string value and its giving error when im trying to convert it into integer using (int)$appnum its trimming the leading zeros. I want this field as the string field and want the leading zeroes as it is. please tell me. how i can sort it in ascending or descening orders (numeric) thanx.
Code:
function seatingOrder(){
$result = $this->database->Query("select id, appnum, name from datFrom SORT BY appnum ASC");
echo '<table cellpadding="5" cellspacing="2" align="center">';
while($rows = mysql_fetch_assoc($result)){
//$app = $rows["appnum"];
//$app = (int)$app;
echo '<tr><td>'.$rows["appnum"].'</td><td>'.$rows["id"].'</td><td>'.$rows["name"].'</td></tr>';
}
echo '</table>';
}
Comment