MYSQL insert id in url
Posted: Fri Apr 15, 2011 2:49 pm
Hi,
I have around 5000 rows in mysql each with unique i.d. Now a field in each row caled boxart holds the url to an image i.e
images/uploads/abcdef.jpg
Now i have had a brainwave to save me alot of time. I have around 3500 images to upload, so i will upload these via FTP instead of individually. Each image is uniquely identified by a 4 digit number which is the same as the row in the DB that the url will be on.
So for example row 4543 has an image 4543.jpg to be uploaded and the following url images/uploads/abcdef.jpg to be inserted into the url. The images/uploads/ is the same directory for all of the images. Only diff is the image name which is the ending of the url. All images are jpg
Now could i insert the url for all the rows by only SQL? So just do it in phpmyadmin? Or would i have to create a php script?
Would the below work?
I have around 5000 rows in mysql each with unique i.d. Now a field in each row caled boxart holds the url to an image i.e
images/uploads/abcdef.jpg
Now i have had a brainwave to save me alot of time. I have around 3500 images to upload, so i will upload these via FTP instead of individually. Each image is uniquely identified by a 4 digit number which is the same as the row in the DB that the url will be on.
So for example row 4543 has an image 4543.jpg to be uploaded and the following url images/uploads/abcdef.jpg to be inserted into the url. The images/uploads/ is the same directory for all of the images. Only diff is the image name which is the ending of the url. All images are jpg
Now could i insert the url for all the rows by only SQL? So just do it in phpmyadmin? Or would i have to create a php script?
Would the below work?
Code: Select all
<?php
include 'config.php';
include 'opendb.php';
$result = mysql_query("SELECT * FROM ccms_gameindex ORDER BY id ASC")
or die(mysql_error());
INSERT INTO ccms_gameindex (boxart) VALUES ("images/uploads/".$id.".jpg")
include 'closedb.php';
?>