Hi All,
Is there any way to update / insert a lot of files (photos) to mysql database?
I have a lot of photos on my website and I want to enter all into database.
Thanks,
Amir
3 replies to this topic
#1
Posted 13 October 2010 - 05:47 AM
|
|
|
#2
Posted 14 October 2010 - 05:40 PM
What exactly is it that you're trying to do? Are you asking how to automate the process of inserting records?
Programming is a journey, not a destination.
#3
Posted 14 October 2010 - 06:31 PM
You can use glob() to fetch an array of image names and then join()/implode() them into the database query.
A simplistic example. This assumes you had set up a simple table with autoincrement and the table is named "photos":
A simplistic example. This assumes you had set up a simple table with autoincrement and the table is named "photos":
$photoarray = array();
foreach (glob('/photos/*.jpg') as $filename) {
$photoarray[] = "'$filename'";
}
$sql = "INSERT INTO photos VALUES (" . join(',', $photoarray) . ")";
$result = mysql_query($sql);
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
#4
Posted 19 October 2010 - 10:22 AM
sorry but is it possible to explain a bit more about your suggestion?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









