I´d like to change urls (from database)
Didn´t know very well what to write on the title, but this is that i need
My website stores files on the server, and each file gets its url stored in the database with other information. Like "http://website.com/folder1/file.xx"
The problem is that i have 500 files inside a folder wich are from different folders. (In the database they are, each one, on these previous folders)
So how would i do to change the /folder1/, /folder2/, /folder3/, etc all to the same folder (the c开发者_运维技巧urrent) from the url stored in the database for each one of these files?
OR MAYBE it would be simplier if i deleted all the files from database and re-insert them? Do you know what php would i use for it? (List the files, and delete the respectives on database)
in your loop on file link create new urls like this
$result = mysql_query("select * from yourtablename");
while($row=mysql_fetch_array($result)){
$newpath = "http://website.com/mynewfolder/";
$filename = basename($row['file_path']);
$newlink = $newpath.$filename;
$update = mysql_query("update yourtablename set url = '".$newlink."' where id = $row['id'] ");
}
精彩评论