I think i need to understand PHP and mySQL a lil better...
| SitePoint Sponsor |



I think i need to understand PHP and mySQL a lil better...
Santosh Sankar
Bullish Bankers



Now that i'm using this script, one thing comes up: what if i wrongly upload an image and want to delete it or want to delete a complete gallery?
How can i delete images from galeries?
Can anyone give me an idea?
thanks



Hmm dunno...lol i never got time to make the gallery...its been tough round here...
Santosh Sankar
Bullish Bankers



guess you'r the only one who marked this thread...![]()



lol i coulda sworn i unsubscribed from it...
Santosh Sankar
Bullish Bankers





Hello : )
Long time since I saw this thread last time, had to read through the posts to see what it was all about.
But to delete an image you would need to
1. Delete the image entry in the database
2. Delete the image/thumbnail file.
If you need to delte whole album, you would first see what images are in it, then delete them as explained above, then simply delete the album from the database.
If you need help for this I can do it : )
Hmm, I'm afraid I never saw this post :/website...where do i put in the database access stuff in ur version??
Still need help?
- website



of course i'd love you help me on exactly deleting either photos or galeries.Originally Posted by website
i must confess i feel a little embarassed from profiting from your offer, but ... i accept it
anyway here its too late now. i'll be back tomorrow
i checked my uploaded files, but images arent there alone, but i guess all together inside some strange kind of files...
you can see an example of my gallery at work here:
http://www.ebi-vasco-gama.rcts.pt/mi...?galeria=1900a
thanks a lot



i googled thumbs.db and found this:
http://www.fcs.iastate.edu/computer/...bs/default.htm
so i guess these files can be deleted with no problems;
so, what i've to find out is the way of buiding a delete query that deletes both the miniature and normal pic from respective folder and also the database/table entry...all in simultaneous action
and also need a kind of a list from where i can choose what to delete





Sorry for late reply, many things going on...
thumbs.db has nothing to do with this I belive. That is simply as explained on the website a file windows uses when showing thumbnails when viewing folders.
Anyhow, can you show my the database layout and how the files are saved. Or do you use the scripts I posted above?
- website



you dont have to be sorry, since its me who's beneficting from it...
thanks for helping
i did use the scripts i think i posted here
if you want i can post the scripts i'm actually using and also the tables i use, too, but i just made minor changes to what was posted here


I'm trying to create something pretty much similar to this, but I need the script to handle 1-10 pictures, AND it must both resize all pictures to a 298 x 224 and make thumbnails of all the pictures.... having a hard job doing this.
Plus of course the fact that all pictures must belong to a specific users item (users can have more than one item)... anyone care to lend out a hand, I would really appreciate it.
I am reading too, but have not been able to do any thing. Too Stupid I guess.





bah, long time since none OO programming, might be some things wrong with this but here it goes:So you dump this in a file called delete.phpPHP Code:<?php
//delete.php
define('LARGE_IMAGE_DIR', 'some/path');
define('THUMBNAIL_DIR', 'some/path');
function erase_img($id, $ext) {
unlink(LARGE_IMAGE_DIR . $id . '.' . $ext);
unlink(THUMBNAIL_DIR . 'thumb_' . $id . '.' . $ext);
}
function delete_img($id) {
if (mysql_query('DELETE FROM Images WHERE id = ' . $id)) {
erase_img($id);
echo('Image has been deleted');
} else {
echo('Error: ' . mysql_error());
}
}
function delete_album($id) {
if (!$rslt = mysql_query('SELECT id FROM Images WHERE Album_id = ' . $id)) {
echo('Error: ' . mysql_error());
}
while($row = mysql_fetch_array($rslt)) {
erase_img($row['id']);
}
$rslt1 = mysql_query('DELETE FROM Images WHERE Album_id = ' . $id);
$rslt2 = mysql_query('DELTE FROM Albums WHERE id = ' . $id);
if ($rslt1 && $rslt2 && $rslt) {
echo 'Album deleted successfully...';
}
}
$id = (int) $_GET['id'];
switch ($_GET['type']) {
case 'img':
delete_img($id);
break;
case 'album':
delete_album($id);
break;
}
?>
The scripts take two parameters in the url,
type which can be either img or album.
id which then refers to either the id of the album or the image.
So to erase album with id number 16 you would run
delete.php?type=album&id=16
and so on. Having trouble understanding?
Anyhow, then you can add links the album pages which then take the id of the album/image and add it to the url of the delete file, then you could delete whole album with one hit.
Hope this works and helps!
- website



hi
i owe you an explanation: its been impossible to me, due to my health, to try your code; as soon as i'm ok again, i'll let you know.
Thank you
Bookmarks