Link wont separete

Hi i have this fetch query which gets all the date frm the database but now i am trying to insert a link in every echo row like a delete link but because i already set the images as hiperlink the other delete hyperlink having the same effect as the image hyperlink how do i separate

<?php
$album_id = $_GET['albums'];
 

$photo = mysql_query("SELECT * FROM photos WHERE album_id='$album_id'");

echo '<div id="wrapper">';
echo '<div id="gallery">';

while ($row = mysql_fetch_assoc($photo))

{
echo '<div class="holder">';
echo  '<div class="thumb"> <a href="photos/thumbs/'. $row['photo_proper'] . '  "><img src="photos/'. $row['photo_proper'] . '  " width="100"  height="100 " /></a>';
    echo $row ['name']."<br /> ";
    echo $row ['description']. " items<br /> ";
    
        echo '<p><a href="delete.php.php">delete</a></p>';

    
echo '</div>';
echo '</div>';
}

echo '</div>';
echo '</div>';

?>

fixed thanks

ok i manage to fix the lightbox link but now the problem is the delete page doesnt not wrk help on that please this is how the delete page looks like

table photos and the fieldname for the image is called photo_proper

<?php
define('ROOT_DIR', './');
define('PROPER', TRUE);

/**
* include common files
*/
include_once(ROOT_DIR. 'includes/common.inc.php');



// No album id has been selected
if (isset($_GET['photo_id']) && isset($_GET['photo_proper'])) {
   // get the image file name so we
   // can delete it from the server
   $sql = "SELECT photo_id, photo_proper
           FROM photos
           WHERE photo_id = {$_GET['photo_id']}
                 AND photo_proper = {$_GET['photo_proper']}";
   $result = mysql_query($sql)
             or die('Delete photo failed. ' . mysql_error());
   if (mysql_num_rows($result) == 1) {
      $row = mysql_fetch_assoc($result);

      // remove the image and the thumbnail from the server
      unlink(GALLERY_IMG_DIR . $row['photo_proper']);
      unlink(GALLERY_IMG_DIR . 'thumbs/' . $row['photo_proper']);

      // and then remove the database entry
      $sql = "DELETE FROM photos
              WHERE photo_id = {$_GET['photo_id']}";
      mysql_query($sql)
      or die('deletd photo failed. ' . mysql_error());
   }
   
}
?>

one tiny little problem why else statment i put at the end not wrking like seleted echo file deleted

yeah sorry missed the dot working great now THANK YOU VERY MUCH:blush::smiley:

this is the whole code do u think might be those headers

<script type="text/javascript" src="js_eurico/jquery.js"></script>
<script type="text/javascript" src="js_eurico/jquery.lightbox-0.5.min.js"></script>

whole code

<?php
define('ROOT_DIR', './');
define('PROPER', TRUE);

/**
* include common files
*/
include_once(ROOT_DIR. 'includes/common.inc.php');



?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="css_eurico/lightbox.css" rel="stylesheet" type="text/css" />
<link href="css_eurico/jquery.lightbox-0.5.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="js_eurico/jquery.js"></script>
<script type="text/javascript" src="js_eurico/jquery.lightbox-0.5.min.js"></script>



<script type="text/javascript">

$(function() {

$('#gallery a').lightBox();

});

</script>


</head>

<body>

<?php
$album_id = $_GET['albums'];
 

$photo = mysql_query("SELECT * FROM photos WHERE album_id='$album_id'");

echo '<div id="wrapper">';
echo '<div id="gallery">';

while ($row = mysql_fetch_assoc($photo))

{
echo '<div class="holder">';
echo  '<div class="thumb"> <a href=home.php><img src="photos/'. $row['photo_proper'] . '  " width="100"  height="100 " /></a>';
    echo $row ['name']."<br /> ";
    echo $row ['description']. " items<br /> ";
    
echo '<p><a href="delete.php.php?id='.$row['id'].'">delete</a></p>'; 

    
    
echo '</div>';
echo '</div>';
}

echo '</div>';
echo '</div>';

?>

</body>
</html>

No, div’s cannot be used as links. Maybe posting the JQuery script might help us understand what you are trying to achieve.

Ok is something to do with the jQuery lightBox plugin the image is a link to the jQuery lightBox plugin as long you have <a hrfe> inside while fetch query pop up the jQuery lightBox plugin even thou i cant see a link to it any idea can div’s be used as hyperlink hiden behind or soemthing??

<?php
$album_id = $_GET['albums'];
 

$photo = mysql_query("SELECT * FROM photos WHERE album_id='$album_id'");

echo '<div id="wrapper">';
echo '<div id="gallery">';

while ($row = mysql_fetch_assoc($photo))

{
echo '<div class="holder">';
echo  '<div class="thumb"> <a href=home.php><img src="photos/'. $row['photo_proper'] . '  " width="100"  height="100 " /></a>';
    echo $row ['name']."<br /> ";
    echo $row ['description']. " items<br /> ";
    
echo '<p><a href="delete.php.php?id='.$row['id'].'">delete</a></p>'; 

    
    
echo '</div>';
echo '</div>';
}

echo '</div>';
echo '</div>';

?>

Do you get an error? Or is the link just not working? If it isn’t do your images have an id in the database?

Right, I don’t know what your code looks like for ‘delete.php.php’ page but you can send data to that page by link through the $_GET method:


echo '<p><a href="delete.php.php?id='.$row['id'].'">delete</a></p>';

The ‘?’ question mark sign is to indicate there’s data to be sent by the GET method. I have used ‘id’ for the data name and the data is placed by using the id number from the database.

i insert that line inside the while fetch is that where i’m suppost to insert correct looks like this bt still not wrking i dnt know if is cz that image link is lightbox Jqury or sunfin bt still not wrking

while ($row = mysql_fetch_assoc($photo))

{
echo '<div class="holder">';
echo  '<div class="thumb"> <a href=photos/thumbs/'. $row['photo_proper'] . '  "><img src="photos/'. $row['photo_proper'] . '  " width="100"  height="100 " /></a>';
    echo $row ['name']."<br /> ";
    echo $row ['description']. " items<br /> ";
    
echo '<p><a href="delete.php.php?id='.$row['id'].'">delete</a></p>'; 

yes

Hi macaela,

Are you trying to make the delete link for each image?

the delete file here
C:\xampp\htdocs\rock\del_photos.php
and the photos file
C:\xampp\htdocs\rock\photos
C:\xampp\htdocs\rock\photos\ humbs
they all in the same directory only that the photos are inside the a photos folder

heres how all looks like now

<?php
define('ROOT_DIR', './');
define('PROPER', TRUE);



/**

* include common files

*/

include_once(ROOT_DIR. 'includes/common.inc.php');







// No album id has been selected

if (isset($_GET['photos'])) 
 {

   // get the image file name so we

   // can delete it from the server

   $sql = "SELECT photo_id, photo_proper

           FROM photos

           WHERE photo_id = {$_GET['photos']}";

   $result = mysql_query($sql)

             or die('Delete photo failed. ' . mysql_error());

   if (mysql_num_rows($result) == 1) {

      $row = mysql_fetch_assoc($result);
      
define("GALLERY_IMG_DIR", "photos/");


      // remove the image and the thumbnail from the server

      unlink(GALLERY_IMG_DIR . $row['photo_proper']);

      unlink(GALLERY_IMG_DIR . 'thumbs/' . $row['photo_proper']);



      // and then remove the database entry

      $sql = "DELETE FROM photos

              WHERE photo_id = {$_GET['photos']}";

      mysql_query($sql)

      or die('deletd photo failed. ' . mysql_error());

   }

  else{
   echo "file deleted";
 }
   

}

?>




Then the path to photo directory is incorrect, or it is correct by PHP is not allowed to remove files from that directory.

Check if the path is correct and if PHP is allowed to delete files from there.

like this
define(“GALLERY_IMG_DIR”, “photos/”);
its only deleting from the database is not removing the images from the folder photos

You forgot the trailing / after photos – see post #18
Also, defines are best put at the start of the file, next to the other defines that are already there :slight_smile:

ok this what i made


define("GALLERY_IMG_DIR","photos");
      // remove the image and the thumbnail from the server
      unlink(GALLERY_IMG_DIR . $row['photo_proper']);

      unlink(GALLERY_IMG_DIR . 'thumbs/' . $row['photo_proper']);

no, define()

I have just tried your script without the lightbox javascript and I can see the thumbnail, details and the delete link underneath each photo.

Are you sending the ablum id number by another page?