[thelist] mysql-changing some but not all info in a column
Nan Smith
nansmith at heritageconcord.org
Sat Sep 28 19:01:01 CDT 2002
>> http:/domain.com/images/nicepic.gif
>
>> becomes
>>
>> http://newdomain.com.au/blah/blah
I was thinking something along the lines of this
(pseudocode solution):
//retrieve each URL in the table using the select function
for each row in the DB
$url = "select column_name from table_name";
//get the length of the string (URL of the image)
$length = strlen($url);
//use the substring function to select the part of the URL
to keep
$part_of_url_to_keep = substr($url, $start, $length);
where $start is the starting point of the URL you want
to stay in the path to the graphic, maybe this would be
16 in this case, which would incude 'images/nicepic.gif'
and remove http://domain.com/
-concatenate http://newdomain/com.au to the front of
$part_of_url_to_keep:
$new_url =
"http://newdomain/com.au/".$part_of_url_to_keep;
then use the update table function to replace the URL
I am leaving out some stuff here, I guess I am assuming
you know this part, if you need help with how to use a
loop to get through all of the rows in the DB, give a
holler.
Nan
More information about the thelist
mailing list