PHP MySQL Notes


Retrieve MySQL records in last first based on a field.

$sql = "select * from (table) ORDER BY (field) DESC";

Format numbers to maintain leading zeros this shows how to maintain 2 places if the digit is 1 it will become 01

$var = str_pad($var, 2, 0, STR_PAD_LEFT);

Comments

Popular Posts