PHP string issue
Posted on 2006-05-02
hello all! i am working with a value from a database, and i want it to act as a string, but it continues to act as a number.
Below is my code:
<? include("dbconn.inc") ?>
function right ($str, $howManyCharsFromRight)
$strLen = strlen ($str);
return substr ($str, $strLen - $howManyCharsFromRight, $strLen);
$customeridquery = "SELECT Customer_ID FROM customers ORDER BY Customer_ID DESC";
$customeridresult = mysql_query($customeridquery);
$lastcustomerid = mysql_result($customeridresult,0);
$lastcustomerid = strval($lastcustomerid);
$lastcustomerid = trim($lastcustomerid);
$lastcustomerid = right($lastcustomerid,4);
$lastcustomerid = $lastcustomerid+1;
$year = date('y');
$customerid = $year.$lastcustomerid;
the output i am expecting of this would be 060002 if the last customer id was 060001.
however, all i am getting is 062 - basically the 000 are being removed because the $lastcustomerid is being treated as a number. any way to make this work properly?