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
https://forums.phpfreaks.com/topic/81530-solved-change-deafult-image/
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());
?>

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.