Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6770309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:17:49+00:00 2026-05-26T15:17:49+00:00

I am having my iPhone app delete a selected image off of my database,

  • 0

I am having my iPhone app delete a selected image off of my database, after it deletes the image i want, it needs to rename all of the other images left in the folder. So say my folder has 3 images: img1, img2, img3 and so on. Say i delete img1, i go ahead and unlink() it and now i need to rename img2 to img1 and then img3 to img2.

Here is my code for right now

<?php
$dbc = mysql_connect('hostname', 'login', 'password');
if(!$dbc){
die('not connected : ' . mysql_error());
}

$db_selected = mysql_select_db("database", $dbc);
if(!$db_selected){
die("could not connect to DB : " . mysql_error());  
}

$username = $_GET['username'];
$image = $_GET['imagename'];

$check = mysql_query("SELECT image FROM members WHERE username='$username'");
$findMem = mysql_num_rows($check);

if($findMem > 0){

while($row = mysql_fetch_array($check) or die(mysql_error())){
$images = $row["image"];
$images = $images - 1;
unlink("./$image");

mysql_query("UPDATE members SET image='$images'
WHERE username='$username'");
}

$path = "$username/default/";


$files = glob("{$path}/{*.jpg,*.jpeg,*.png}", GLOB_BRACE);


function filetime_callback($a, $b)
{
  if (filemtime($a) === filemtime($b)) return 0;
  return filemtime($a) > filemtime($b) ? -1 : 1; 
} 

// Then sort with usort()
usort($files, "filetime_callback");

}

?>

As you see i have a function set up that will order all of the files by the date created.

I still want the dates created to stay the same, i just need to rename the files inside the folder. There could be 50 images, so its going to have to be some sort of loop.

Thanks for the help 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:17:50+00:00Added an answer on May 26, 2026 at 3:17 pm

    See http://php.net/manual/en/function.rename.php

    You should probably look at relying on some other mechanism for ordering your files though. I’d suggest that you add an order by field in your database and sort based on that. That way you can have your files sorted independent of the name that you give them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having difficulty with images in my iPhone app. I load an image
I'm having issues with my webserver and iPhone app, considering the timezone. It's all
I just created an iPhone app and am having friends try it out, but
I'm having a problem with building my iPhone app..so, i finally finished it, but
Im having a problem opening the settings preferences in my IOS iphone app. At
I have an IPhone application which is having a non consumable in app purchse
I am having an issue in iphone when i want to use a custom
I'm working on an iPhone app, and I'm having some compiler trouble. Here's the
I track user activity in my iPhone app by having certain user actions call
I am having an issue with my UITextFields in my iPhone app that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.