Glese Posted January 10, 2012 Share Posted January 10, 2012 I am wondering is it possible to calculate with an alphernumeric ID in PHP, can PHP basically make sense out of an ID like c04 ? I used such ID system for the category system because I was able to make more sense out of the c in front of the number, which is not necessarily needed. Would a SQL calculation like "$category_id + 1" work? Whereas $category_id stands for c04 and becomes a c05 after calculation. Link to comment https://forums.phpfreaks.com/topic/254713-calculate-with-an-alphernumeric-id/ Share on other sites More sharing options...
Andy-H Posted January 10, 2012 Share Posted January 10, 2012 "SELECT CONCAT(SUBSTR('c04', 1, 1), IF(LENGTH(SUBSTR('c04', 2) +1) = 1, CONCAT('0', SUBSTR('c04', 2) +1), SUBSTR('c04', 2) +1)) AS test" Link to comment https://forums.phpfreaks.com/topic/254713-calculate-with-an-alphernumeric-id/#findComment-1306056 Share on other sites More sharing options...
Glese Posted January 10, 2012 Author Share Posted January 10, 2012 If it is that complex I will rather opt for a solely numeric system, I like to keep it simple, the letter was not necessary anyway, I just could make more sense out of it. Link to comment https://forums.phpfreaks.com/topic/254713-calculate-with-an-alphernumeric-id/#findComment-1306066 Share on other sites More sharing options...
Andy-H Posted January 10, 2012 Share Posted January 10, 2012 Just store the c part separately. Link to comment https://forums.phpfreaks.com/topic/254713-calculate-with-an-alphernumeric-id/#findComment-1306201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.