dynamic insert php mysql and preformance

Posted by Ross on Stack Overflow See other posts from Stack Overflow or by Ross
Published on 2010-04-16T06:43:18Z Indexed on 2010/04/16 6:53 UTC
Read the original article Hit count: 592

Filed under:
|
|
|

I have a folder/array of images, it may be 1, maximum of 12. What I need to do is dynamically add them so the images are added to an images table.

At the moment I have

 $directory = "portfolio_images/$id/Thumbs/";
 $images = glob("" . $directory . "*.jpg");

  for ( $i= 0; $i <= count($images); $i += 1) {

 mysql_query("INSERT INTO project_images  (image_name, project_id)VALUES ('$images[0]', '$id')") or die(mysql_error());

 }

this is fine but it does not feel right, how is this for performance? Is there a better way?

The maximum number of images is only ever going to be 12.

Thanks,

Ross

© Stack Overflow or respective owner

Related posts about mysql

Related posts about insert