Jump to content

SUBSTR not working with numbers


affc

Recommended Posts

Hello,

 

This code used to work by placing a "0" infront of a number if it was only between 1-9 it would make it 01-09. Now it simply puts a 1 infront of it so 11-19 which isn't what Im after. Was there a code upgrade I missed? Thanx in advance

 

$sql6="SELECT * FROM $tbl_name7";

$result6=mysql_query($sql6);

$count3=mysql_num_rows($result6);

$COUNTS =$count3+1;

$number=$_GET['No'];

$THISNUMBER = substr("$COUNTS".$number, -2);

Link to comment
https://forums.phpfreaks.com/topic/143025-substr-not-working-with-numbers/
Share on other sites

Hi thank you for the replied but that doesn't work for what I am after.

 

I have a GET function that will get a number such as "1" from the address bar. I want to add a 0 at the beginning and so on up to 9 and any number after that is left alone but limited to only 2 digit numbers for the result. I cant seem to get it to put a 0 at the start anymore so 1 becomes 01 and so on.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.