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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.