Jump to content

Build an array from database


gavin.sibley

Recommended Posts

hello,

 

i am trying to get this code to select a set of links from a database and then add the to the folder to be zipped, everything seems to be working apart from it doesnt seem to pull the url's to add to the end of the file_get_contents line, anyone have any ideas?

 

<?php
include("config.php");
require ("zipfile.inc.php");
$zipfile = new zipfile();
$filedata = implode("", file("zipfile.inc.php"));

$getspdi = mysql_query("SELECT * FROM `wedding_photos` WHERE `user_hash` = '$_GET[id]' ORDER BY `id` DESC LIMIT 0, 1000") or die(mysql_error());
$getspd = mysql_fetch_array($getspdi);

while ($photos = mysql_fetch_array($getspdi)) {
$zipfile->add_file(file_get_contents("/var/www/vhosts/mydomain.com/httpdocs-entertainment/wuploads/"), "$photos[img]");
echo("/var/www/vhosts/soundboxaudio.com/httpdocs-entertainment/wuploads/ <br />");
}

header("Content-disposition: attachment; filename=spd_$_GET[title]_$_GET[fname]_$_GET[lname]__$_GET[photos]_Photos.zip");
echo $zipfile->file();
?>

 

many thanks,

gavin

Link to comment
https://forums.phpfreaks.com/topic/263052-build-an-array-from-database/
Share on other sites

One more mistake.

 

use

while ($photos = mysql_fetch_array($getspd))

instead of

while ($photos = mysql_fetch_array($getspdi))

Uh no. It should be $getspdi.

 

However the

$getspd = mysql_fetch_array($getspdi);

line is a problem. It'll make the loop skip the first row in the resultset. Get rid of it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.