Remix919
04-30-2011, 04:22 PM
Hey, I'm importing a bunch of pictures into a database and I want the first pic imported to have the $pickey of 1 and the second 2 and so forth. Here is my code:
foreach(array_slice($imgdata, 0) as $key=>$value) {
$pickey = 1;
$pickey++;
$url = $value;
$fname = basename("$url");
$destination = "/home/autolib/public_html/files/listing_orig_$fname";
copyemz ($url, $destination);
echo "$url - $fname <a href=http://autolibrium.com/files/listing_orig_$fname>check</a><br><br>";
//copy ("$url","/home/autolib/public_html/files/listing_orig_$fname");
$imagephoto = new SimpleImage();
$imagephoto->load($destination);
$imagephoto->resize(550,370);
$imagephoto->save("/home/autolib/public_html/files/listing_photo_$fname");
$imagephoto->resize(106,80);
$imagephoto->save("/home/autolib/public_html/files/listing_thumbnail_$fname");
mysql_query("INSERT INTO fl_listing_photos (ID, Listing_ID, Position, Photo, Thumbnail, Original) VALUES ('','$newlisting[ID]','$pickey','listing_photo_$fname','listing_thumbnail_$fname','listing_orig_$fname')");
}
Could someone let me know what I'm doing wrong because it keeps showing the Position as 0 instead of the $pickey number.
foreach(array_slice($imgdata, 0) as $key=>$value) {
$pickey = 1;
$pickey++;
$url = $value;
$fname = basename("$url");
$destination = "/home/autolib/public_html/files/listing_orig_$fname";
copyemz ($url, $destination);
echo "$url - $fname <a href=http://autolibrium.com/files/listing_orig_$fname>check</a><br><br>";
//copy ("$url","/home/autolib/public_html/files/listing_orig_$fname");
$imagephoto = new SimpleImage();
$imagephoto->load($destination);
$imagephoto->resize(550,370);
$imagephoto->save("/home/autolib/public_html/files/listing_photo_$fname");
$imagephoto->resize(106,80);
$imagephoto->save("/home/autolib/public_html/files/listing_thumbnail_$fname");
mysql_query("INSERT INTO fl_listing_photos (ID, Listing_ID, Position, Photo, Thumbnail, Original) VALUES ('','$newlisting[ID]','$pickey','listing_photo_$fname','listing_thumbnail_$fname','listing_orig_$fname')");
}
Could someone let me know what I'm doing wrong because it keeps showing the Position as 0 instead of the $pickey number.