Re: Mysql look up and then rename
| From: | Marek Kilimajer | Date: | Fri, 19 Mar 2004 11:52:03 +0000 |
| Subject: | Re: Mysql look up and then rename | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-180951@lists.php.net to get a copy of this message | ||
Brent Clark wrote:
Hi all
for some reason I seem to be having a problem having to do a look up in a mysql table
and the take the result of that query and then perform the right action.
Basically I need to do a look up for a file for example
10006547.pdf.
I then need to:
if no letter of the alphabet is present.
then make it 10006547A.pdf
else if does exist, make it 10006547B.pdf
for some reason I cant seem to pull this off, add I honestly thought is would be a simple function.
If anyone knows of a URL or can help in anyway
preg_match() to find the letter (or no letter if there is not any)
ord() will give you the ASCII value of the character, you can now add 1 to it, watch for the ceiling (Z)
chr() to give you the letter from the new ASCII value
Don't forget to lock your table to be safe from simultaneously running requests:
myqsl_query('LOCK TABLES tbl_name [AS alias] {READ | WRITE}');