How can i rename a part from a cell in a data table

i have the folowing table

id -------------- 35
albumdescription -------------- test 1
name -------------- 001.jpg
type -------------- image
size -------------- 97182
location -------------- test 1/thumbs/thumb001.jpg
location1 -------------- test 1/slides/001.jpg

I can change albumdescription and folder with

if(isset($_POST['change_name_alb_wein']))
{
	$namealbum= $_POST['change_album_name'];
	$idalb=$_POST['id_wein_album'];	
	$namechange = $_POST['andere_namen_wein_album'];
	$change_name = trim($namechange);

	if (file_exists($namealbum)) {
	rename ($namealbum, $change_name); 

	$db="blabla";
$connect = mysql_connect("localhost","blabla","blabla");
if (! $connect)die("Couldn't connect to MySQL");
mysql_select_db($db , $connect)or die("Couldn't open $db: ".mysql_error());


mysql_query(" UPDATE narr_weinachtfeier SET albumdescription='$change_name','location=' WHERE id='$idalb");

But how can i change
location test 1/thumbs/thumb001.jpg
location1 test 1/slides/001.jpg

everywhere location and location1 begins with test1/thumbs/thumb001.jpg

i only want to change - test 1 - into something else shal we say - album 1/thumbs/thumb001.jpg - and for location1 into album 1/slides/001.jpg.

thanks in advice John

Recommended Answers

All 2 Replies

carefully use this code, before running this query, keep back up of table

mysql_query("UPDATE narr_weinachtfeier SET albumdescription='$change_name',
location=  concat('$change_name',substr(location,instr(location,'/'))) ,
location1=  concat('$change_name',substr(location1,instr(location1,'/')))
WHERE id='$idalb'"

Thanks for the quick reply
Works great

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.