need to convert this i think to php, this has the functions i need to image swap the photos but wont save the changes.
i think i need to store all the src in a file to display images as an array then when i make a change with image swap to automatically save the array or have update button to save new array.
here is the code i currently have as an example just with function
any help will be greatly appreciated

Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Swap demo</title>

<style type="text/css">
#GALLERY td {
height: 200px; width: 200px;
text-align: center;
vertical-align: middle;
}
#GALLERY td img, #GALLERY td img.normal {
border: solid white 5px;
}
#GALLERY td img.highlighted {
border: solid red 5px;
}
</style>

</head>
<body>
  <table id="GALLERY">
  <tr>
      <td>
          <img src="http://www.clearviewarts.com/thumbnails/Puppy In Basket.jpg"      alt="Dogs"/>          
      </td>
      <td>
          <img src="http://www.clearviewarts.com/thumbnails/BabyIndy.jpg" alt="Dogs"/>          
      </td>
      <td>
          <img src="http://www.clearviewarts.com/thumbnails/HarlequinDane.jpg" alt="Dogs"/>          
      </td>
  </tr>
  <tr>
      <td>
          <img src="http://www.clearviewarts.com/thumbnails/Pug.jpg" alt="Dogs"/>          
      </td>
      <td>
          <img src="http://www.clearviewarts.com/thumbnails/Wagner-edit1.jpg" alt="Dogs"/>          
      </td>
      <td>
          <img src="http://www.clearviewarts.com/thumbnails/CanusAngelicus.jpg" alt="Dogs"/>          
      </td>
  </tr>
  </table>

<script type="text/javascript">
var pix = document.getElementById("GALLERY").getElementsByTagName("img");
for ( var p = 0; p < pix.length; ++p )
{
pix[p].onclick = picclick;
}

var firstImage = null;
function picclick( )
{
// to cancel a swap, click on first image again:
if ( firstImage == this ) 
{
    this.className = "normal";
    firstImage = null;
    return;
}
// is this first image clicked on?
if ( firstImage == null )
{
    // yes
    firstImage = this;
    this.className = "highlighted";
    return; // nothing more to do
}
// aha! second image clicked on, so do swap
firstImage.className = "normal";
var temp = this.src;
this.src = firstImage.src;
firstImage.src = temp;
firstImage = null;

}
</script>
</body>
</html>