Jump to content

bob_the _builder

Members
  • Posts

    206
  • Joined

  • Last visited

Everything posted by bob_the _builder

  1. Hi, Not really sure what you mean by call on the delete query? Thanks
  2. Hi, I guess you mean something like: [code=php:0] $sql = mysql_query("DELETE gallery_images, gallery_subcat FROM gallery_images, gallery_subcat, gallery_maincat WHERE gallery_maincat.maincat_id = gallery_subcat.maincat_id AND gallery_images.subcat_id = gallery_subcat.subcat_id AND gallery_maincat.maincat_id = '".$_GET['maincat_id']."'") or die(mysql_error()); while($row = mysql_fetch_array($sql)) {     unlink($images_dir . '/' . $row['photo_filename']);     unlink($images_dir . '/tb_' . $row['photo_filename']); $subcat_id = $row['subcat_id']; $maincat_id = $row['maincat_id']; } mysql_query ("DELETE FROM gallery_images WHERE subcat_id = '".$subcat_id."'") or die(mysql_error()); mysql_query ("DELETE FROM gallery_subcat WHERE subcat_id = '".$subcat_id."'") or die(mysql_error()); mysql_query ("DELETE FROM gallery_maincat WHERE maincat_id = '".$_GET['maincat_id']."'") or die(mysql_error());[/code] Same issue, doesnt delete any subcats that dont contain images from the table  ??? Also gives and error:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ... Thanks
  3. I couldnt get the original code you posted to work .. Here is what I have from your original code, it unlinks the images, but doesnt delete any mysql records, doesnt seem to bring back any errors neither. I had to alter some of the field names from your original to suit the databse: [code=php:0]$sql = mysql_query("SELECT i.photo_filename,  i.subcat_id, m.maincat_id FROM gallery_images i INNER JOIN gallery_subcat s     ON s.subcat_id = i.subcat_id INNER JOIN gallery_maincat m     ON m.maincat_id = s.maincat_id WHERE m.maincat_id='".$_GET['maincat_id']."'") or die(mysql_error()); while (list($photo_filename, $subcat_id, $maincat_id) = @mysql_fetch_row($sql)) {     unlink($images_dir . '/' . $photo_filename);     unlink($images_dir . '/tb_' . $photo_filename); } mysql_query ("DELETE FROM gallery_images WHERE subcat_id = '$subcat_id'") or die(mysql_error()); mysql_query ("DELETE FROM gallery_subcat WHERE subcat_id = '$subcat_id'") or die(mysql_error()); mysql_query ("DELETE FROM gallery_maincat WHERE maincat_id = '$maincat_id'") or die(mysql_error());[/code]
  4. Hi, Just 1 thing ... your contact form, it clears the form when submited with missing fields, you should echo the post data in the fields so they dont have to retype the data if they miss a field out. Nice job!
  5. Hi, I have noticed a flaw in the delete maincat code: It only works if a subcat has images within it, if there are 2 subcats and only 1 has images it will remove the maincat, the subcat with images + the images but leaves the 2nd maincat which has no images behind in the database. Cheers
  6. Thanks [quote author=Barand link=topic=106575.msg427052#msg427052 date=1157280985] I was trying to avoid the redundant delete queries. I guess the $subcat and $maincat values were being cleared once it hit the end of the result set. [/quote] Does that mean your structure is a better way to do it? With the random image, there is no user data being passed, its just a query that shows all tha categories and shows a random image from the subcats that relate to each individual main cat. Thanks
  7. Does the trick using: [code=php:0]$sql = mysql_query("SELECT i.photo_filename, i.subcat_id, m.maincat_id FROM gallery_images i INNER JOIN gallery_subcat s     ON s.subcat_id = i.subcat_id INNER JOIN gallery_maincat m     ON m.maincat_id = s.maincat_id WHERE m.maincat_id='".$_GET['maincat_id']."'") or die(mysql_error()); while($row = mysql_fetch_array($sql)) {     @unlink($images_dir . '/' . $row['photo_filename']);     @unlink($images_dir . '/tb_' . $row['photo_filename']); mysql_query ("DELETE FROM gallery_images WHERE subcat_id = '".$row['subcat_id']."'") or die(mysql_error()); mysql_query ("DELETE FROM gallery_subcat WHERE subcat_id = '".$row['subcat_id']."'") or die(mysql_error()); mysql_query ("DELETE FROM gallery_maincat WHERE maincat_id = '".$row['maincat_id']."'") or die(mysql_error()); }[/code] Im not familiar with: [code=php:0]while (list($photo, $subcat, $maincat) = @mysql_fetch_row($sql)) {[/code] Would a similar structure be used to grab a random image from any subcat related to each maincat in the loop Thanks
  8. Hi, That only seems to unlink the images, but leaves all mysql records in their tables .. Have tried a few changes and there doesnt seem to be any more errors. But still not removing any or the records in mysql at all: [code=php:0]$sql = mysql_query("SELECT i.photo_filename,  i.subcat_id, m.maincat_id FROM gallery_images i INNER JOIN gallery_subcat s     ON s.subcat_id = i.subcat_id INNER JOIN gallery_maincat m     ON m.maincat_id = s.maincat_id WHERE m.maincat_id='".$_GET['maincat_id']."'") or die(mysql_error()); while (list($photo_filename, $subcat_id, $maincat_id) = @mysql_fetch_row($sql)) {   @unlink($images_dir . '/' . $photo);     @unlink($images_dir . '/tb_' . $photo); } mysql_query ("DELETE FROM gallery_images WHERE subcat_id = '$subcat_id'") or die(mysql_error()); mysql_query ("DELETE FROM gallery_subcat WHERE subcat_id = '$subcat_id'") or die(mysql_error()); mysql_query ("DELETE FROM gallery_maincat WHERE maincat_id = '$maincat_id'") or die(mysql_error());[/code] Is that nearer to how it should be? All these WHERE maincat_id = '$maincat_id had no _id at the end. Thanks
  9. Thanks, that removes the images from the server .. Is there away to delete the gallery_images data and unlink the related images in a single query like I have with the subcat function? Thanks
  10. Hi, Yep thats what I am trying to do, but also get the photo_filename field from the gallery_images table and use it with the unlink functions you see in the script. Here I have managed to remove subgallery and all its images: [code=php:0] if (array_key_exists("confirm",$_REQUEST)) { $sql = mysql_query("SELECT photo_filename FROM gallery_images WHERE subcat_id='".$_GET['subcat_id']."'"); while ($row = @mysql_fetch_array($sql)) {   unlink($images_dir . '/' . $row[0]);   unlink($images_dir . '/tb_' . $row[0]); } $sql = mysql_query("DELETE FROM gallery_images WHERE subcat_id='".$_GET['subcat_id']."'");     $sql = mysql_query("DELETE FROM gallery_subcat WHERE subcat_id='".$_GET['subcat_id']."'");[/code] Which works great, but when it comes to deleting a maincat, all its subcats and images im stuck, as the link to delete maincat only holds the value $row['maincat_id'] which doesnt relate to the gallery_images table at all .. hence the join or what ever is needed to create the link? Im stuck .. have no idea how to make it work :( Thanks
  11. Hi, Looks like that tut shows how to store the images within the database .. Im sure the best option is to store the name+extension in the database and the photo/file in a folder on the server. Post what code you have if you get stuck.
  12. Hi, Its just a random image from any subcat related to each maincat in the loop. Here is what I have for your posted code: [code=php:0]$sql = mysql_query("DELETE gallery_subcat, gallery_images FROM gallery_subcat, gallery_images, gallery_maincat WHERE gallery_maincat.maincat_id = gallery_subcat.maincat_id AND gallery_images.subcat_id = gallery_subcat.subcat_id AND gallery_maincat.maincat_id = '".$_GET['maincat']."'") or die(mysql_error()); while ($row = mysql_fetch_array($sql)) { unlink($images_dir . '/' . $row["photo_filename"]);   unlink($images_dir . '/tb_' . $row["photo_filename"]); }     $sql = mysql_query("DELETE FROM gallery_subcat WHERE maincat_id='".$_GET['maincat_id']."'"); $sql = mysql_query("DELETE FROM gallery_maincat WHERE maincat_id='".$_GET['maincat_id']."'");[/code] I get an error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource Also tried: [code=php:0]$sql = mysql_query("DELETE from gallery_images WHERE subcat_id IN ( SELECT maincat_id                         FROM gallery_subcat                       WHERE maincat_id=".$_GET['maincat_id'].")") or die(mysql_error()); while ($row = mysql_fetch_array($sql)) { unlink($images_dir . '/' . $row["photo_filename"]);   unlink($images_dir . '/tb_' . $row["photo_filename"]); }     $sql = mysql_query("DELETE FROM gallery_subcat WHERE maincat_id='".$_GET['maincat_id']."'"); $sql = mysql_query("DELETE FROM gallery_maincat WHERE maincat_id='".$_GET['maincat_id']."'");[/code] Thats deletes everything but the "gallery_images" records and doesnt unlink the images. Thanks
  13. Hi, Create table stuctures to hold the data you would like to hold [code]CREATE TABLE links (   link_id int(5) NOT NULL auto_increment,   link_name varchar(50) NOT NULL default '',   notes text NOT NULL default '',   PRIMARY KEY (link_id) ) TYPE=MyISAM;[/code] Then use forms to post the data [code=php:0] // Connection details somewhere if isset($_POST['submit']) { $sql = mysql_query("INSERT INTO links (link_name, notes) VALUES ('".$_POST['links'].", ".$_POST['notes']."')"); echo '<br />URL successfully added'; }else{ echo '<form id="form" name="links" method="post" action="">   <input type="text" name="textfield" />   <br /><br />   <textarea name="" cols="" rows=""></textarea>   <br /><br />   <input name="submit" type="submit" value="submit" />   </form>'; }[/code] Only budget concept .. You will need to use 'multipart/form-data' for images/files, store the image names + extension in the database and the images in a folder on your server hth
  14. Hi, First my table structures are: [code]CREATE TABLE gallery_maincat (   maincat_id int(20) NOT NULL auto_increment,   maincat_name varchar(50) NOT NULL default '',   PRIMARY KEY (maincat_id) ) TYPE=MyISAM; CREATE TABLE gallery_subcat (   subcat_id int(20) NOT NULL auto_increment,   maincat_id int(20) NOT NULL,   subcat_name varchar(50) NOT NULL default '',   PRIMARY KEY (subcat_id) ) TYPE=MyISAM; CREATE TABLE gallery_images (   photo_id int(20) NOT NULL auto_increment,   subcat_id int(20) NOT NULL,   photo_filename varchar(25) default '',   photo_caption text,   PRIMARY KEY (photo_id) ) TYPE=MyISAM;[/code] Im having issue trying to write 2 table joins .. 1st is to show a random image for the main categories that corospond to the subcategories. The 2nd is to delete all images and related name to the main category and subcategory, the only information posted is the maincat_id, so a table join is needed to match the maincat_id to the sub[color=black][/color]cat_id Any ideas on the correct structure? Thanks
  15. Hi, yep along those lines .. but also to create enough extra space in the popup to display the photo description and a link to close the window. Thanks
  16. Nope that will be the path to where you shifted the image upon upload: $images_dir = 'images/gallery'; hth
  17. Hi, Store the filename.extension in your databse .. then you use that to match the image name to the image [code=php:0]<img src="'.$images_dir.'/'.$row['photo_filename'].'">';[/code] hth
  18. Should be able to copy and paste into the text area .. maybe you are trying to paste more code than the limit allowed here?
  19. Ok, I have some javascript at presant that works, But I cant make it allow room for the image description and a close window link, It all ends up hidden behind the image.
  20. Hi lounger, Not following your request that well, can you post some code to give a better idea on what you are trying to acheive? Thanks
  21. reword I think: Have it so you click on a link and have it open the image in a new window (popup effect), then using php have it resize the browser to the image size + enough to show the descripton and a link to close the window. Thanks
  22. Works using: &referer='.urlencode($_SERVER["HTTP_REFERER"]).' then: <meta http-equiv="refresh" content="3; url='.$_GET['referer'].'"> Thanks!
  23. Hi, Is it posible to make a popup window that will resize to the image size + room for the desciption using php without any javascript? The description is stored in the database and the image name+extension is stored in the database with the images in a folder on the server. Thanks
  24. Still not working .. Tried: &referer='.$_SERVER["HTTP_REFERER"].'?'.$_SERVER['QUERY_STRING'].' and: <meta http-equiv="refresh" content="3; url='.$_GET['referer'].'"> but still get: http://localhost/gallery/index.php?action=sh_subcat but it should be: http://localhost/gallery/index.php?action=sh_subcat&subcatid=4 Thanks
  25. Thanks, Is it bad pratice sending the url across like that to $_GET it at the destination?
×
×
  • 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.