Jump to content

need help please


richarro1234

Recommended Posts

<?include("header.php");?>
<?
if ($_GET['note'] == 'deleted') {
	$note = "<br><center>
			 <table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' width='75%' id='AutoNumber1' bordercolor='red' bgcolor='#000000'>
				<tr>
				  <td width='100%' class=trnext align='center'><font color='red' size='2'><b>Your images have been deleted successfully!</b></font></td>
				</tr>
			 </table>
			 </center><br>";
	}
include("data.php");
mysql_connect($server,$anvandare, $losen);
mysql_select_db($databas);
$query = mysql_query("SELECT * from richspri_social.users WHERE username = '".$_COOKIE["twusername"]."'");
while ($r = @mysql_fetch_array($query)) {
$approv = $r['id'];

?>

<?
if ($_GET['action'] == 'deletemulti') {

foreach($_POST['deleted_items'] as $v){
    mysql_query("delete from richspri_social.userimg where file_name IN($v)");
}

foreach($_POST['deleted_items'] as  $deleted){
    unlink($deleted);
}

header ("Location: approveimg.php?note=deleted");
die();
}
?>

<?}?>
<center>
<?=$note?></center>
<br>
<div align="center">
  <center>
<div align="center">
  <center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#5D6765" width="95%" id="AutoNumber1" bgcolor="#131313">
  <tr>
    <td width="5%" align="center" bgcolor="#000000"><b>Delete</b></td>
    <td width="16%" align="center" bgcolor="#000000"><b>Picture</b></td>
    <td width="16%" align="center" bgcolor="#000000"><b>User Edited</b></td>
    <td width="16%" align="center" bgcolor="#000000"><b>Value Edited</b></td>
    <td width="16%" align="center" bgcolor="#000000"><b>Original Value</b></td>
    <td width="15%" align="center" bgcolor="#000000"><b>New Value</b></td>
    <td width="16%" align="center" bgcolor="#000000"><b>Date</b></td>
  </tr>
  <tr>
    <td width="100%" align="center" colspan="6"> </td>
  </tr>
  <form action="approveimg.php?action=deletemulti" name="approv" method="post">
<?
$results= mysql_query("SELECT * FROM richspri_social.userimg WHERE approved = 'no'"); 
$id = "id";
$filename = "file_name";
$filesize = "filesize";
$filetype = "filetype";
$desc = "description";
$ownerid = "ownerid";
$path = "filepath";

echo mysql_error();

if (mysql_Numrows($results)>0)                            //if there are records in the fields
{ 
  $numrows=mysql_NumRows($results);                       //count them
  $x=0; 
  while ($x<$numrows){   //loop through the records

    $theid=mysql_result($results,$x,$id);
    $thename=mysql_result($results,$x,$filename);
    $thesize=mysql_result($results,$x,$filesize);
    $theowner=mysql_result($results,$x,$ownerid);
    $thetype=mysql_result($results,$x,$filetype);
    $thedesc=mysql_result($results,$x,$desc);
    $thepath=mysql_result($results,$x,$path);
    
?>

  <tr>
    <td width="5%" align="center"><input type="checkbox" class="normal" value="<?=$theid?>" name="deleted_items[]">
    <td width="16%" align="center"><a href="../userimages/<?=$thename;?>"><img src="..//userimages/<?=$thename?>" width="100" height="100"></a> </td>
    <td width="16%" align="center"><a href="profile.php?id=<?=$memlink['id'];?>"><?=$theusername?></a> </td>
    <td width="16%" align="center"><?=$theaction?> </td>
    <td width="16%" align="center"><?=$theorigvalue?> </td>
    <td width="15%" align="center"><?=$thenewvalue?> </td>
    <td width="16%" align="center"><?=$logdate?> </td>
  </tr>

<?
    $x++;
  }
?>
<td width="5%" align="center" bgcolor="#000000"><input type="submit" value="DEL"></td>
    <td width="95%" align="center" colspan="3" bgcolor="#000000"><font size="2"><b><a href="#" onclick="setCheckboxes('approv', true); return false;">Select All</a>
| <a href="#" onclick="setCheckboxes('approv', false); return false;">Unselect All</a></b></font></td>
  </form
</table>
  </center>
</div>
<?php } else {
?>
</center>
<center><b>There Are No New Images to Approve!</b></center>
<br>
<?
}
?>
      </td>
    </tr>
  </table>
  </center>
</div>
<br>
<?include("footer.php");?>

 

Hey there,

i have a folder called userimg where the files upload to, the above file is located in/admin/.

i newed the above code to delete MULTIPLE files (which are sleected from the form under the mysql)

AND delete the rows from the mysql database.

 

At the moment it deletes the files form userimg, but it doesnt dleete it from the database,

can someone help with the code so that it will delete the file and then dleete it form the database.

 

Thanks

Rich

Link to comment
https://forums.phpfreaks.com/topic/139785-need-help-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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