Jump to content

[SOLVED] change deafult image


timmah1

Recommended Posts

I'm trying to switch default images.

 

The database has a field name "main", the default is set to '0', when it is the default image, it gets set to '1'.

 

 

If I want to switch one photo for the other, how would I change the photo's id to reflect this change at the same time?

 

Example:

 

name                main

top.jpg                0

bottom.jpg          1

 

But I want to make top '1' and bottom '0'. How is this done at the same time?

 

I hope I worded this correctly and you understand.

 

Thanks for your help in advance.

 

 

Link to comment
Share on other sites

carry across the id number of the pic to be come the new "default"

then do something like

<?php
$id = 2;
//connect sql
$q = "Update `Default_Images` Set `Default` = '0'";
$r = mysql_query($q) or die(mysql_error());
$q = "Update `Default_Images` Set `Default` = '1' where ImageID = '".$id."'";
$r = mysql_query($q) or die(mysql_error());
?>

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.