Jump to content

delete images


searls03

Recommended Posts

it has something to do with this......I changed checkbox to text and it is empty......how could I fix this?\

    $content .= "<input name=\"check[]\" type=\"text\" value='".$row['pic_id']."' /><img src='/$image' width='190' height='150'/></a><br />
";}

Link to comment
Share on other sites

so now I changed it to this......

<?php
session_start(); // Must start session first thing
/* 
Created By Adam Khoury @ www.flashbuilding.com 
-----------------------June 20, 2008----------------------- 
*/
// Here we run a login check
if (!isset($_SESSION['id'])) { 
   echo 'Please <a href="/login.php">log in</a> to access your account';
   exit(); 
}

//Connect to the database through our include 
include_once "connect_to_mysql.php";
// Place Session variable 'id' into local variable
$userid = $_SESSION['id'];
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM members WHERE userid='$userid' LIMIT 1");
while($row = mysql_fetch_array($sql)){
$name = $row["name"];
$phone = $row["phone"];
$username = $row["username"];
$address = $row["address"];
$city = $row["city"];
$state = $row["state"];
$zip = $row["zip"];
$cell = $row["cell"];
$email = $row["email"];
$accounttype = $row["accounttype"];
$rank = $row["rank"];
$badges = $row["badges"];
$userid = $row["userid"];

}

?>
<?php
include_once "connect_to_mysql.php";

// if no id is specified, list the available articles


   $query = "SELECT image, event, name, id, site, pic_id FROM pictures where id='".$_GET['id']."'";
   $result = mysql_query($query) or die('Error : ' . mysql_error());
  
   // create the article list

   while($row = mysql_fetch_array($result, MYSQL_NUM))
   {
      list($image, $event, $name, $id, $site, $pic_id) = $row;
  
      $content .= "<input name=\"check[]\" type=\"checkbox\" value=$pic_id /><img src='/$image' width='190' height='150'/></a><br />
";}
   ?>
   <?php
include_once "connect_to_mysql.php";

// if no id is specified, list the available articles


   $query = "SELECT image, event, name, id, site, pic_id FROM pictures GROUP BY event";
   $result = mysql_query($query) or die('Error : ' . mysql_error());
  
   // create the article list

   while($row = mysql_fetch_array($result, MYSQL_NUM))
   {
      list($image, $event, $name, $id, $site, $picid) = $row;
  
      
  $content1 .= "<option value=\"$id\">$event </option></li>";
   }
   ?>
   <?php
if (isset($_POST['delete_images']))
    {
        if(is_array($_POST['check']))
        {
            $ids = implode(',', $_POST['check']);

            
echo '<pre>'; print_r($_POST['check']); echo '</pre>'; 
   


   
$q =  "DELETE FROM  pictures WHERE pic_id = IN($ids)";$sql = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()) ; }



}
   

?>
<!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=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="picsman.php" method="get">
  <select name="id">
  <?php echo $content1; ?>
</select>
  <input type="submit" name="select" id="select" value="Select Event" />
</form>
<form action="picsman.php" method="post">
<?php
echo $content; 
?>
<input type="submit" name="delete_images" value="delete images" /></form>

</body>
</html>

 

but now I get:

Array

(

    [0] => 11

    [1] => 12

)

 

Problem with the query: DELETE FROM pictures WHERE pic_id = IN(11,12)

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN(11,12)' at line 1

Link to comment
Share on other sites

is this correct way to delete from server?

<?php
session_start(); // Must start session first thing
/* 
Created By Adam Khoury @ www.flashbuilding.com 
-----------------------June 20, 2008----------------------- 
*/
// Here we run a login check
if (!isset($_SESSION['id'])) { 
   echo 'Please <a href="/login.php">log in</a> to access your account';
   exit(); 
}

//Connect to the database through our include 
include_once "connect_to_mysql.php";
// Place Session variable 'id' into local variable
$userid = $_SESSION['id'];
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM members WHERE userid='$userid' LIMIT 1");
while($row = mysql_fetch_array($sql)){
$name = $row["name"];
$phone = $row["phone"];
$username = $row["username"];
$address = $row["address"];
$city = $row["city"];
$state = $row["state"];
$zip = $row["zip"];
$cell = $row["cell"];
$email = $row["email"];
$accounttype = $row["accounttype"];
$rank = $row["rank"];
$badges = $row["badges"];
$userid = $row["userid"];

}

?>
<?php
include_once "connect_to_mysql.php";

// if no id is specified, list the available articles


   $query = "SELECT image, event, name, id, site, pic_id FROM pictures where id='".$_GET['id']."'";
   $result = mysql_query($query) or die('Error : ' . mysql_error());
  
   // create the article list

   while($row = mysql_fetch_array($result, MYSQL_NUM))
   {
      list($image, $event, $name, $id, $site, $pic_id) = $row;
  
      $content .= "<input name=\"check[]\" type=\"checkbox\" value=$pic_id /><img src='/$image' width='190' height='150'/></a><br />
";}
   ?>
   <?php
include_once "connect_to_mysql.php";

// if no id is specified, list the available articles


   $query = "SELECT image, event, name, id, site, pic_id FROM pictures GROUP BY event";
   $result = mysql_query($query) or die('Error : ' . mysql_error());
  
   // create the article list

   while($row = mysql_fetch_array($result, MYSQL_NUM))
   {
      list($image, $event, $name, $id, $site, $picid) = $row;
  
      
  $content1 .= "<option value=\"$id\">$event </option></li>";
   }
   ?>
   <?php
if (isset($_POST['delete_images']))
    {
        if(is_array($_POST['check']))
        {
            $ids = implode(',', $_POST['check']);

            
   


   
$q =  "DELETE FROM  pictures WHERE pic_id IN($ids)";$sql = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()) ; }

if(is_file("$image")) {
unlink("$image");
}



}
   

?>

<!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=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="picsman.php" method="get">
  <select name="id">
  <?php echo $content1; ?>
</select>
  <input type="submit" name="select" id="select" value="Select Event" />
</form>
<form action="picsman.php" method="post">
<?php
echo $content; 
?>
<?php
if (isset($_GET['id'])) {
?>
<input type="submit" name="delete_images" value="delete images" /></form>
<?php } ?>

</body>
</html>

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.