Forums

PHP

This topic is locked

Updating Multiple Records using Repeat Region

Posted 09 Aug 2010 23:21:04
1
has voted
09 Aug 2010 23:21:04 Bobby Edgar posted:
I have a site where folks post their resumes and photos. I want to be able to let those folks remove certain photos and change the order that they are displayed in their profiles.

I created a page that list all of their photos in a form based on their username once they log in. Under each photo there is also a checkbox to "remove" the photo if they wish (it doesn't actually delete it, it just changes the status from "Approved" to "Not Approved" and only "Approved" photos are displayed).

I added a repeat region to that area of the page, but the submit button is only shown once. I want the people to go through the photos and pick the ones they want to remove, hit submit, and all of those records will update.

I did all of that and it only updates the first record in the list no matter which record in the repeated regions I change.

Here's The Code I am Referring To: (There is also a seperate form to allow them upload a new photo on the page and that works just fine)

<?php
// *** Restrict Access To Page: Grant or deny access to this page
$FF_authorizedUsers=" ";
$FF_authFailedURL="../../index.php";
$FF_grantAccess=0;
session_start();
if (isset($HTTP_SESSION_VARS["MM_Username"])) {
  if (true || !(isset($HTTP_SESSION_VARS["MM_UserAuthorization"])) || $HTTP_SESSION_VARS["MM_UserAuthorization"]=="" || strpos($FF_authorizedUsers, $HTTP_SESSION_VARS["MM_UserAuthorization"])) {
    $FF_grantAccess = 1;
  }
}
if (!$FF_grantAccess) {
  $FF_qsChar = "?";
  if (strpos($FF_authFailedURL, "?")) $FF_qsChar = "&";
  $FF_referrer = $HTTP_SERVER_VARS['PHP_SELF'];
  if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && strlen($HTTP_SERVER_VARS['QUERY_STRING']) > 0) $FF_referrer .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
  $FF_authFailedURL = $FF_authFailedURL . $FF_qsChar . "accessdenied=" . urlencode($FF_referrer);
  header("Location: $FF_authFailedURL");
  exit;
}

// Pure PHP Upload 2.1.10
$ppu = new pureFileUpload();
$ppu->path = "../../photos/";
$ppu->extensions = "GIF,JPG,JPEG,BMP,PNG";
$ppu->formName = "new_photo";
$ppu->storeType = "file";
$ppu->sizeLimit = "";
$ppu->nameConflict = "uniq";
$ppu->requireUpload = "true";
$ppu->minWidth = "";
$ppu->minHeight = "";
$ppu->maxWidth = "";
$ppu->maxHeight = "";
$ppu->saveWidth = "";
$ppu->saveHeight = "";
$ppu->timeout = "600";
$ppu->progressBar = "";
$ppu->progressWidth = "";
$ppu->progressHeight = "";
$ppu->redirectURL = "";
$ppu->checkVersion("2.1.10");
$ppu->doUpload();

// Smart Image Processor 1.0.7
if (isset($HTTP_GET_VARS['GP_upload'])) {
  $sip = new resizeUploadedFiles($ppu);
  $sip->component = "ImageMagick";
  $sip->resizeImages = "true";
  $sip->aspectImages = "true";
  $sip->maxWidth = "600";
  $sip->maxHeight = "600";
  $sip->quality = "80";
  $sip->makeThumb = "true";
  $sip->pathThumb = "../../photos/thumbs/";
  $sip->aspectThumb = "true";
  $sip->naming = "prefix";
  $sip->suffix = "thumb_";
  $sip->maxWidthThumb = "300";
  $sip->maxHeightThumb = "";
  $sip->qualityThumb = "70";
  $sip->checkVersion("1.0.7");
  $sip->doResize();
}

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if (isset($editFormAction)) {
  if (isset($_SERVER['QUERY_STRING'])) {
   if (!eregi("GP_upload=true", $_SERVER['QUERY_STRING'])) {
     $editFormAction .= "&GP_upload=true";
  }
  } else {
    $editFormAction .= "?GP_upload=true";
  }
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "new_photo")) {
  $insertSQL = sprintf("INSERT INTO Photos (Photo_Name, Photo_Approved, UniqueID, User_Email, User_FirstName, User_LastName, Photo_Order) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Photo_Name'], "text"),
                       GetSQLValueString($_POST['Photo_Approved2'], "text"),
                       GetSQLValueString($_POST['UniqueID'], "text"),
                       GetSQLValueString($_POST['User_Email'], "text"),
                       GetSQLValueString($_POST['User_FirstName'], "text"),
                       GetSQLValueString($_POST['User_LastName'], "text"),
                       GetSQLValueString($_POST['Photo_Order'], "int"));

  mysql_select_db($database_Resumes_DB, $Resumes_DB);
  $Result1 = mysql_query($insertSQL, $Resumes_DB) or die(mysql_error());
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "Edit_Photos")) {
  $updateSQL = sprintf("UPDATE Photos SET photo_approved="%s," top_photo="%s" WHERE photo_id="%s"",
                       GetSQLValueString(isset($_POST['Photo_Approved']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString($_POST['Top_Photo'], "text"),
                       GetSQLValueString($_POST['Photo_ID'], "text"));

  mysql_select_db($database_Resumes_DB, $Resumes_DB);
  $Result1 = mysql_query($updateSQL, $Resumes_DB) or die(mysql_error());
}

$colname_rsPhotos = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_rsPhotos = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_Resumes_DB, $Resumes_DB);
$query_rsPhotos = sprintf("SELECT * FROM Photos WHERE User_Email = '%s' AND Photo_Approved = 'Y' ORDER BY Photo_Order ASC", $colname_rsPhotos);
$rsPhotos = mysql_query($query_rsPhotos, $Resumes_DB) or die(mysql_error());
$row_rsPhotos = mysql_fetch_assoc($rsPhotos);
$totalRows_rsPhotos = mysql_num_rows($rsPhotos);

$colname_rsPhotoCount = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_rsPhotoCount = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
mysql_select_db($database_Resumes_DB, $Resumes_DB);
$query_rsPhotoCount = sprintf("SELECT * FROM Photos WHERE User_Email = '%s' ORDER BY Posted_Date ASC", $colname_rsPhotoCount);
$rsPhotoCount = mysql_query($query_rsPhotoCount, $Resumes_DB) or die(mysql_error());
$row_rsPhotoCount = mysql_fetch_assoc($rsPhotoCount);
$totalRows_rsPhotoCount = mysql_num_rows($rsPhotoCount);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset="iso-8859-1"" />
<title>Untitled Document</title>
<link href="../../stylenew.css" rel="stylesheet" type="text/css" />
<script language="'javascript'" src="'../../ScriptLibrary/incPureUpload.js'></script>"
</head>

<body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="spotlight_photo_border">
  <tr>
    <td><form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="new_photo" id="new_photo" document.MM_returnValue">
      <table width="100%" border="0" cellspacing="2" cellpadding="2">
        <tr>
          <td><div align="center">You Can Add A New Photo To Your Website Here.</div></td>
        </tr>
        <tr>
          <td><div align="center">
            <label>
            <input name="Photo_Name" type="file" class="Register_Forms" id="Photo_Name" />
            </label>
            <label>
            <input name="Submit" type="submit" class="Register_Forms" value="Submit" />
            </label>
            <input name="UniqueID" type="hidden" id="UniqueID" value="HIDDEN" />
            <input name="User_FirstName" type="hidden" id="User_FirstName" value="HIDDEN" />
            <input name="User_LastName" type="hidden" id="User_LastName" value="HIDDEN" />
            <input name="Photo_Approved2" type="hidden" id="Photo_Approved2" value="Y" />
            <input name="User_Email" type="hidden" id="User_Email" value="HIDDEN" />
            <input name="Photo_Order" type="hidden" id="Photo_Order" value="<?php echo $row_rsPhotoCount['Photo_Order']+1; ?>" />
          </div></td>
        </tr>
      </table>
            <input type="hidden" name="MM_insert" value="new_photo">
    </form>
    </td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="2" cellpadding="2">
      <tr>
        <td height="30" valign="bottom"><div align="center">You Can Remove Your Photos Here. You Can Also Choose/Change The 1st Photo. </div></td>
      </tr>
      <tr>
        <td><form action="<?php echo $editFormAction; ?>" id="Edit_Photos" name="Edit_Photos" method="POST">
          <div align="center">
                <?php do { ?>
                  <table width="300" border="0" align="center" cellpadding="2" cellspacing="2" class="spotlight_photo_border">
                    <tr>
                      <td colspan="2"><div align="center">[img]../../photos/thumbs/thumb_<?php echo $row_rsPhotos['Photo_Name']; ?>" width="300" /><br />
                        </div></td>
                        </tr>
                    <tr>
                      <td width="148" valign="middle"></td>
                        <td width="146" valign="middle"></td>
                        </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" valign="middle">Remove This Photo </td>
                              <td width="12%" valign="middle">
                                <input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
                                <input name="Photo_ID" type="hidden" id="Photo_ID" value="<?php echo $row_rsPhotos['Photo_ID']; ?>" /></td>
                              <td width="31%" valign="middle"><div align="center">Make 1st Photo  </div></td>
                              <td width="20%" valign="middle">
                                <div align="center">
                                  <input <?php if (!(strcmp($row_rsPhotos['Top_Photo'],"Y"))) {echo "checked=\"checked\"";} ?> name="Top_Photo" type="radio" class="Register_Forms" value="Y" />
                              </div>    </td>
                              </tr>
                        </table></td>
                        </tr>
                      </table>
                  <?php } while ($row_rsPhotos = mysql_fetch_assoc($rsPhotos)); ?><input name="Submit2" type="submit" class="Register_Forms" value="Submit" />
          </div>
          <input type="hidden" name="MM_update" value="Edit_Photos">
        </form>
        </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsPhotos);
mysql_free_result($rsPhotoCount);
?>

Edited by - Bobby Edgar on 12 Aug 2010  16:11:58

Replies

Replied 12 Aug 2010 16:12:40
12 Aug 2010 16:12:40 Bobby Edgar replied:
Anybody...? Can someone please help with this?
Replied 13 Aug 2010 13:35:51
13 Aug 2010 13:35:51 Patrick Woldberg replied:
Dreamweaver by default has no support for updating multiple records at once. In your code all checkboxes have the same name and it will just take the first or last.

See a tutorial like www.dmxzone.com/go?17550 or search for other code for updating/deleting multiple records at once.
Replied 14 Aug 2010 06:09:20
14 Aug 2010 06:09:20 Bobby Edgar replied:
Actually the update is setup to use the Photo_ID as the Primary Key and in Page View, all of the photos are shown and their Photo_Ids are all different. There HAS TO be a way to do this. Here is the Page View when viewed online.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="../../stylenew.css" rel="stylesheet" type="text/css" />
<script language='javascript' src='../../ScriptLibrary/incPureUpload.js'></script>
</head>
 
<body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" class="spotlight_photo_border">
  <tr>
    <td><form action="/admin/edits/photos.php?&GP_upload=true" method="POST" enctype="multipart/form-data" name="new_photo" id="new_photo" onsubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','','');return document.MM_returnValue">
      <table width="100%" border="0" cellspacing="2" cellpadding="2">
        <tr>
          <td><div align="center">You Can Add A New Photo To Your Website Here.</div></td>
        </tr>
        <tr>
          <td><div align="center">
            <label>
            <input name="Photo_Name" type="file" class="Register_Forms" id="Photo_Name" onchange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','','')" />
            </label>
            <label>
            <input name="Submit" type="submit" class="Register_Forms" value="Submit" />
            </label>
            <input name="UniqueID" type="hidden" id="UniqueID" value="REMOVED" />
            <input name="User_FirstName" type="hidden" id="User_FirstName" value="REMOVED" />
            <input name="User_LastName" type="hidden" id="User_LastName" value="REMOVED" />
            <input name="Photo_Approved2" type="hidden" id="Photo_Approved2" value="Y" />
            <input name="User_Email" type="hidden" id="User_Email" value="REMOVED" />
            <input name="Photo_Order" type="hidden" id="Photo_Order" value="10" />
          </div></td>
        </tr>
      </table>
            <input type="hidden" name="MM_insert" value="new_photo">
    </form>
    </td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="2" cellpadding="2">
      <tr>
        <td height="30" valign="bottom"><div align="center">You Can Remove Your Photos Here. You Can Also Choose/Change The 1st Photo. </div></td>
      </tr>
      <tr>
        <td><form action="/admin/edits/photos.php?&GP_upload=true" id="Edit_Photos" name="Edit_Photos" method="POST">
          <div align="center">
                                  <table width="300" border="0" align="center" cellpadding="2" cellspacing="2" class="spotlight_photo_border">
                    <tr>
                      <td colspan="2"><div align="center">[img]../../photos/thumbs/thumb_IMG_1445.JPG" width="300" /><br />
                        </div></td>
                        </tr>
                    <tr>
                      <td width="148" valign="middle"></td>
                        <td width="146" valign="middle"></td>
                        </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" valign="middle">Remove This Photo </td>
                              <td width="12%" valign="middle">
                                <input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
                                <input name="Photo_ID" type="hidden" id="Photo_ID" value="16" /></td>
                              <td width="31%" valign="middle"><div align="center">Make 1st Photo  </div></td>
                              <td width="20%" valign="middle">
                                <div align="center">
                                  <input checked="checked" name="Top_Photo" type="radio" class="Register_Forms" value="Y" />
                              </div>    </td>
                              </tr>
                        </table></td>
                        </tr>
                      </table>
                                    <table width="300" border="0" align="center" cellpadding="2" cellspacing="2" class="spotlight_photo_border">
                    <tr>
                      <td colspan="2"><div align="center">[img]../../photos/thumbs/thumb_IMG_1403.JPG" width="300" /><br />
                        </div></td>
                        </tr>
                    <tr>
                      <td width="148" valign="middle"></td>
                        <td width="146" valign="middle"></td>
                        </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" valign="middle">Remove This Photo </td>
                              <td width="12%" valign="middle">
                                <input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
                                <input name="Photo_ID" type="hidden" id="Photo_ID" value="19" /></td>
                              <td width="31%" valign="middle"><div align="center">Make 1st Photo  </div></td>
                              <td width="20%" valign="middle">
                                <div align="center">
                                  <input  name="Top_Photo" type="radio" class="Register_Forms" value="Y" />
                              </div>    </td>
                              </tr>
                        </table></td>
                        </tr>
                      </table>
                                    <table width="300" border="0" align="center" cellpadding="2" cellspacing="2" class="spotlight_photo_border">
                    <tr>
                      <td colspan="2"><div align="center">[img]../../photos/thumbs/thumb_IMG_1486.JPG" width="300" /><br />
                        </div></td>
                        </tr>
                    <tr>
                      <td width="148" valign="middle"></td>
                        <td width="146" valign="middle"></td>
                        </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" valign="middle">Remove This Photo </td>
                              <td width="12%" valign="middle">
                                <input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
                                <input name="Photo_ID" type="hidden" id="Photo_ID" value="17" /></td>
                              <td width="31%" valign="middle"><div align="center">Make 1st Photo  </div></td>
                              <td width="20%" valign="middle">
                                <div align="center">
                                  <input  name="Top_Photo" type="radio" class="Register_Forms" value="Y" />
                              </div>    </td>
                              </tr>
                        </table></td>
                        </tr>
                      </table>
                                    <table width="300" border="0" align="center" cellpadding="2" cellspacing="2" class="spotlight_photo_border">
                    <tr>
                      <td colspan="2"><div align="center">[img]../../photos/thumbs/thumb_37802_421411699543_678364543_4613861_1095936_n.jpg" width="300" /><br />
                        </div></td>
                        </tr>
                    <tr>
                      <td width="148" valign="middle"></td>
                        <td width="146" valign="middle"></td>
                        </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" valign="middle">Remove This Photo </td>
                              <td width="12%" valign="middle">
                                <input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
                                <input name="Photo_ID" type="hidden" id="Photo_ID" value="15" /></td>
                              <td width="31%" valign="middle"><div align="center">Make 1st Photo  </div></td>
                              <td width="20%" valign="middle">
                                <div align="center">
                                  <input  name="Top_Photo" type="radio" class="Register_Forms" value="Y" />
                              </div>    </td>
                              </tr>
                        </table></td>
                        </tr>
                      </table>
                                    <table width="300" border="0" align="center" cellpadding="2" cellspacing="2" class="spotlight_photo_border">
                    <tr>
                      <td colspan="2"><div align="center">[img]../../photos/thumbs/thumb_Jackie_as_Lucy_-_Avenue_Q.jpg" width="300" /><br />
                        </div></td>
                        </tr>
                    <tr>
                      <td width="148" valign="middle"></td>
                        <td width="146" valign="middle"></td>
                        </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" valign="middle">Remove This Photo </td>
                              <td width="12%" valign="middle">
                                <input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
                                <input name="Photo_ID" type="hidden" id="Photo_ID" value="27" /></td>
                              <td width="31%" valign="middle"><div align="center">Make 1st Photo  </div></td>
                              <td width="20%" valign="middle">
                                <div align="center">
                                  <input  name="Top_Photo" type="radio" class="Register_Forms" value="Y" />
                              </div>    </td>
                              </tr>
                        </table></td>
                        </tr>
                      </table>
                                    <table width="300" border="0" align="center" cellpadding="2" cellspacing="2" class="spotlight_photo_border">
                    <tr>
                      <td colspan="2"><div align="center">[img]../../photos/thumbs/thumb_n68121440_35332263_1562.jpg" width="300" /><br />
                        </div></td>
                        </tr>
                    <tr>
                      <td width="148" valign="middle"></td>
                        <td width="146" valign="middle"></td>
                        </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" valign="middle">Remove This Photo </td>
                              <td width="12%" valign="middle">
                                <input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
                                <input name="Photo_ID" type="hidden" id="Photo_ID" value="14" /></td>
                              <td width="31%" valign="middle"><div align="center">Make 1st Photo  </div></td>
                              <td width="20%" valign="middle">
                                <div align="center">
                                  <input  name="Top_Photo" type="radio" class="Register_Forms" value="Y" />
                              </div>    </td>
                              </tr>
                        </table></td>
                        </tr>
                      </table>
                                    <table width="300" border="0" align="center" cellpadding="2" cellspacing="2" class="spotlight_photo_border">
                    <tr>
                      <td colspan="2"><div align="center">[img]../../photos/thumbs/thumb_n24300895_31436232_1683.jpg" width="300" /><br />
                        </div></td>
                        </tr>
                    <tr>
                      <td width="148" valign="middle"></td>
                        <td width="146" valign="middle"></td>
                        </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" valign="middle">Remove This Photo </td>
                              <td width="12%" valign="middle">
                                <input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
                                <input name="Photo_ID" type="hidden" id="Photo_ID" value="13" /></td>
                              <td width="31%" valign="middle"><div align="center">Make 1st Photo  </div></td>
                              <td width="20%" valign="middle">
                                <div align="center">
                                  <input  name="Top_Photo" type="radio" class="Register_Forms" value="Y" />
                              </div>    </td>
                              </tr>
                        </table></td>
                        </tr>
                      </table>
                                    <table width="300" border="0" align="center" cellpadding="2" cellspacing="2" class="spotlight_photo_border">
                    <tr>
                      <td colspan="2"><div align="center">[img]../../photos/thumbs/thumb_n511166646_1012376_2878.jpg" width="300" /><br />
                        </div></td>
                        </tr>
                    <tr>
                      <td width="148" valign="middle"></td>
                        <td width="146" valign="middle"></td>
                        </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" valign="middle">Remove This Photo </td>
                              <td width="12%" valign="middle">
                                <input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
                                <input name="Photo_ID" type="hidden" id="Photo_ID" value="12" /></td>
                              <td width="31%" valign="middle"><div align="center">Make 1st Photo  </div></td>
                              <td width="20%" valign="middle">
                                <div align="center">
                                  <input  name="Top_Photo" type="radio" class="Register_Forms" value="Y" />
                              </div>    </td>
                              </tr>
                        </table></td>
                        </tr>
                      </table>
                                    <table width="300" border="0" align="center" cellpadding="2" cellspacing="2" class="spotlight_photo_border">
                    <tr>
                      <td colspan="2"><div align="center">[img]../../photos/thumbs/thumb_n26100171_32696972_8943.jpg" width="300" /><br />
                        </div></td>
                        </tr>
                    <tr>
                      <td width="148" valign="middle"></td>
                        <td width="146" valign="middle"></td>
                        </tr>
                    <tr>
                      <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="37%" valign="middle">Remove This Photo </td>
                              <td width="12%" valign="middle">
                                <input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
                                <input name="Photo_ID" type="hidden" id="Photo_ID" value="11" /></td>
                              <td width="31%" valign="middle"><div align="center">Make 1st Photo  </div></td>
                              <td width="20%" valign="middle">
                                <div align="center">
                                  <input  name="Top_Photo" type="radio" class="Register_Forms" value="Y" />
                              </div>    </td>
                              </tr>
                        </table></td>
                        </tr>
                      </table>
                  <input name="Submit2" type="submit" class="Register_Forms" value="Submit" />
          </div>
          <input type="hidden" name="MM_update" value="Edit_Photos">
        </form>
        </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>


Edited by - Bobby Edgar on 14 Aug 2010  06:12:30
Replied 17 Aug 2010 17:07:33
17 Aug 2010 17:07:33 Patrick Woldberg replied:
Of course the IDs from the database are unique, but the name of the input fields are for all the same. In php to submit multiple values you should name your input like Photo_ID[], using the brackets will submit it as array.

Here some inputs from your code (I stripped some html):
<input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />  
<input name="Photo_ID" type="hidden" id="Photo_ID" value="16" />
<input checked="checked" name="Top_Photo" type="radio" class="Register_Forms" value="Y" />

<input name="Photo_Approved" type="checkbox" class="Register_Forms" id="Photo_Approved" value="N" />
<input name="Photo_ID" type="hidden" id="Photo_ID" value="19" />
<input  name="Top_Photo" type="radio" class="Register_Forms" value="Y" />


If I retrieve with php $_POST['PhotoID'], which one do I get? The way your form is build won't work.

Reply to this topic