PDA

View Full Version : Newbie question on loading mysql table


EricSanchez3099
08-04-2004, 08:42 AM
Hello all, I'm trying to make a simple photog gallery, using phpmyadmin....but I need to load the table with all the image filenames. i.e.: pic001.jpg, pic002.jpg, pic003.jpg, ....... I don't want to sit there entering every single filename (if I dont have to). My question is, is there any way I can write an SQL script, to automatically load, let's say .... pic001.jpg - pic300.jpg into the mySQL database? Is there such thing? Any help would be appreciated

bcarl314
08-04-2004, 01:55 PM
Hmm, not sure if there's an elegant SQL solution, but you could do it with PHP...

pseudo-code:

connect to DB
select DB
for($i=1; $i<=300; $i++) {
"INSERT INTO DB VALUES ('pic$i.jpg')";
}
close connection

EricSanchez3099
08-04-2004, 06:56 PM
Thanks bcarl. I didn't think about that, and I think that should solve it. Thanks again