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 7723031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:20:25+00:00 2026-06-01T04:20:25+00:00

I am trying to set a default image for my image upload form. In

  • 0

I am trying to set a default image for my image upload form. In the database I have the column “deafult_image” and it will be set to 1 for default and set to 0 if the image is not default.

My problem right now is I can update a row to 1 to make an image the default but if another image exists and is default “1” then I will have 2 default images. How can i update my default image but also change the current default image to 0 at the same time to make it not default anymore.

The media_id column is unique.
link_id is not and could have multiple images for any given link_id.

Here is what I came up with for updating the row to make the image default.

$media = $_GET['media_id'];
$media_id = '1';
$sql = "select * FROM images where media_id = '$media'";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)){
mysql_query("UPDATE images SET default_image='$media_id' where media_id = '$media'") ;
}

What should I do to find if another image with the same link_id exists and change it from 1 to 0 if it is default. There is always a default image for every link_id so I need to update to the current default image.

Also I know I need to validate, this is just for testing.

  • 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-06-01T04:20:27+00:00Added an answer on June 1, 2026 at 4:20 am

    This will reset every image to 0

    $sql = "UPDATE images SET default_image='0'";
    

    This will set your relevant image as the default

    $sql = "UPDATE images SET default_image='1' where media_id = '$media'";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I'm trying to set the default audio device on Windows 7 programmatically,
I am trying to set some default inherited permissions to a directory that will
I'm using SlickGrid with DataView and I'm trying to set a default sort column
How can I set as a default image a gif, via css. I'm trying
I'm trying to use jquery to set some default text in a form input.
When am trying to set default date and default sysdate am getting following errors:
I'm trying to set default scope according to some criteria determined by ana ActionController
I'm trying to set a default value for a search field. The idea is
I'm trying to set my default page to Index.html on an ASP.NET site running
I am trying to set my columns default date time to system datetime. It

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.