hansontango
New Member
In the admin section of my website there is a button that extracts an Excel file with data from my database. In reality, it is an Excel file that is created upon clicking the button using PEAR. I use an SQL query to get the information necessary from my SQL Server 2008 database.One of the columns named 'number1' contains a number ranging from 1-9999. I have been looking for a way to have it put zeros in front of the numbers when it doesnt have 4 digits already, but I've had no luck until now. For example, if the number in the database is 12, I would like it to show as 0012 in my Excel sheet.currently the code used is the following:\[code\]if ($j == 15){$worksheet->write($variable1, $j , $variable2[$i][$j], $text222); }where $variable1 = 0; $variable2 = ("my sql query")\[/code\]Your help is appreciated.