Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Dreamweaver Update Record Server Behaviour & Go To Updated Record

Posted on 2011-05-11
17
Medium Priority
?
510 Views
Last Modified: 2012-05-11
Hi,

I have a master results page (results.php) which displays several hundred database records, retrieved using a recordset and a repeat region.  One can then click on edit to go to a seperate page (update.php) which then uses the Dreamweaver Update Record Server Behaviour.  When I submit the updated record, I'd really like to return to the record's place in the master results list.  Is this possible?

Thanks

J
0
Comment
Question by:xtbarton
  • 9
  • 8
17 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35738452
Hi xtbarton,

Does the user have to click anything to get to the place in the master list to begin with?
0
 

Author Comment

by:xtbarton
ID: 35738470
Hi,

Not at present; there are no anchors in the page at all.  It's just a collection of several hundred records organised by date ascending.  

Thanks.  
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35738824
So you would need to create anchors in order for this to work and pass the anchor to edit page and then have the edit page build it into the URL for the return trip.

The other way to do it would be to get a little clever with AJAX and have your edit form appear in a modal overlay on the list page.  That way, the user never leaves and never loses position.
0
Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

 

Author Comment

by:xtbarton
ID: 35738878
Thanks; my PHP is a bit limited as yet, so can you offer any more clues?  How do I go about creating the anchor in the repeat region that's passed to the edit page and then how do I submit this as a return variable?  
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35738918
Can you paste the repeat region section of the table here and I'll give it a shot?

Stepping into a meeting now so I'll be back in an hour or so
0
 

Author Comment

by:xtbarton
ID: 35739099
Thanks Jason; code is:
      <?php do { ?>
    </p>
    <div align="left">
      <table width="823" border="0">
        <tr>
          <td width="350" height="58"><em><?php echo $row_rsGNresults['newspaper']; ?></em></td>
          <td width="463"><?php echo date("Y F j", strtotime($row_rsGNresults['date'])); ?></td>
        </tr>
        <tr>
          <td height="48" colspan="2"><?php echo $row_rsGNresults['entry']; ?></td>
        </tr>
        <tr>
          <td height="31" colspan="2"><?php echo nl2br($row_rsGNresults['comments']); ?></td>
        </tr>
        <tr>
          <td width="100"><a href="update.php?id=<?php echo $row_rsGNresults['id']; ?>">Edit</a></td>
          <td width="100"><a href="delete.php?id=<?php echo $row_rsGNresults['id']; ?>" onclick="tfm_confirmLink('Are you sure you want to delete this record?');return document.MM_returnValue">Delete</a></td>
        </tr>
      </table>
    </div>
  
   
    <hr />
<?php } while ($row_rsGNresults = mysql_fetch_assoc($rsGNresults)); ?>
</div>

Open in new window

0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35740311
So, after line 2 add this:

<a name="<?php echo $row_rsGNresults['id']; ?>"></a>

That generates the anchor.

Change line 16 like so:

<td width="100"><a href="update.php?id=<?php echo $row_rsGNresults['id']; ?>#<?php echo $row_rsGNresults['id']; ?>">Edit</a></td>

The above will use the id number as both the query string and anchor tag on update.php page.  Dreamweaver SHOULD preserve the # reference in the redirect and the resulting URL will return the user back to the same spot.
0
 

Author Comment

by:xtbarton
ID: 35745020
Thanks Jason.  I can see now that when I click on a record to edit, it appends the URL with /update.php?id=1705#1705.  Do I need to update the 'go to' statement on the update.php page?  I.e.

 $updateGoTo = "admin/results.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

Open in new window

0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35746953
Does the existing code do the redirect and preserve the # ?

Test it.  If so, there is no further need to edit.  If not...
0
 

Author Comment

by:xtbarton
ID: 35747035
When I submit the update page, it does maintain the id in the URL of the results page it returns to, i.e. results.php?id=1938.  Unfortunately, it still just takes me back to the top of the results page rather than to the record in the page.

Thanks.  
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35747176
Okay, so it doesn't preserve the anchor.  Let me figure out how to tweak that code.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35749190
On the update page, what is the code for the recordset ID?  I need it to show you how to change the one line in the redirect code...
0
 

Author Comment

by:xtbarton
ID: 35749383
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
  $updateSQL = sprintf("UPDATE gemnews_tab SET category=%s, `language`=%s, newspaper=%s, `date`=%s, issue=%s, works=%s, entry=%s, comments=%s WHERE id=%s",
                       GetSQLValueString($_POST['category3'], "text"),
                       GetSQLValueString($_POST['language2'], "text"),
                       GetSQLValueString($_POST['newspaper'], "text"),
                       GetSQLValueString(make_date_string($_POST['date']), "date"),
                       GetSQLValueString($_POST['issue'], "text"),
                       GetSQLValueString($_POST['works2'], "text"),
                       GetSQLValueString($_POST['entry2'], "text"),
                       GetSQLValueString($_POST['comments'], "text"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_UtOrpheus, $UtOrpheus);
  $Result1 = mysql_query($updateSQL, $UtOrpheus) or die(mysql_error());

  $updateGoTo = "results.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_rsGNupdate = "-1";
if (isset($_GET['id'])) {
  $colname_rsGNupdate = $_GET['id'];
}
mysql_select_db($database_UtOrpheus, $UtOrpheus);
$query_rsGNupdate = sprintf("SELECT * FROM gemnews_tab WHERE id = %s", GetSQLValueString($colname_rsGNupdate, "int"));
$rsGNupdate = mysql_query($query_rsGNupdate, $UtOrpheus) or die(mysql_error());
$row_rsGNupdate = mysql_fetch_assoc($rsGNupdate);
$totalRows_rsGNupdate = mysql_num_rows($rsGNupdate);
?>

Open in new window


And in the body:
  <form id="form2" name="form2" method="POST" action="<?php echo $editFormAction; ?>">
      <h2>Update Record</h2>
      <table width="764" height="90" border="0" class="content">
        <tr>
          <td width="276" height="44"><label for="newspaper">Newspaper</label>
          <input name="newspaper" type="text" id="newspaper" value="<?php echo $row_rsGNupdate['newspaper']; ?>" /></td>
          <td width="227"><label for="issue2">Issue</label>
          <input name="issue" type="text" id="issue2" value="<?php echo $row_rsGNupdate['issue']; ?>" /></td>
          <td width="239"><label for="date2">Date</label>
          <input name="date" type="text" id="date2" value="<?php echo date("Y, F j", strtotime ($row_rsGNupdate['date'])); ?>
" /></td>
        </tr>
        <tr>
          <td><label for="category2">Category</label>
            <select name="category3" id="category2" title="<?php echo $row_rsGNupdate['category']; ?>">
              <option selected="selected" value="" <?php if (!(strcmp("", $row_rsGNupdate['category']))) {echo "selected=\"selected\"";} ?>></option>
              <option value="Concert" <?php if (!(strcmp("Concert", $row_rsGNupdate['category']))) {echo "selected=\"selected\"";} ?>>Concert</option>
              <option value="Publication" <?php if (!(strcmp("Publication", $row_rsGNupdate['category']))) {echo "selected=\"selected\"";} ?>>Publication</option>
              <option value="Sale" <?php if (!(strcmp("Sale", $row_rsGNupdate['category']))) {echo "selected=\"selected\"";} ?>>Sale</option>
              <option value="Clocks" <?php if (!(strcmp("Clocks", $row_rsGNupdate['category']))) {echo "selected=\"selected\"";} ?>>Clocks</option>
          </select></td>
          <td><label for="language2">Language</label>
            <select name="language2" id="language2" title="<?php echo $row_rsGNupdate['language']; ?>">
              <option selected="selected" value="" <?php if (!(strcmp("", $row_rsGNupdate['language']))) {echo "selected=\"selected\"";} ?>></option>
              <option value="EN" <?php if (!(strcmp("EN", $row_rsGNupdate['language']))) {echo "selected=\"selected\"";} ?>>English</option>
              <option value="FR" <?php if (!(strcmp("FR", $row_rsGNupdate['language']))) {echo "selected=\"selected\"";} ?>>French</option>
              <option value="HL" <?php if (!(strcmp("HL", $row_rsGNupdate['language']))) {echo "selected=\"selected\"";} ?>>Dutch</option>
            </select>
          <label for="works2"></label></td>
          <td><label for="works3">Works</label>
            <select name="works2" id="works3" title="<?php echo $row_rsGNupdate['works']; ?>">
              <option selected="selected" value="" <?php if (!(strcmp("", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>></option>
              <option value="Opus 1" <?php if (!(strcmp("Opus 1", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 1</option>
              <option value="Opus 2" <?php if (!(strcmp("Opus 2", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 2</option>
              <option value="Opus 3" <?php if (!(strcmp("Opus 3", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 3</option>
              <option value="Opus 4" <?php if (!(strcmp("Opus 4", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 4</option>
              <option value="Opus 5" <?php if (!(strcmp("Opus 5", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 5</option>
              <option value="Opus 6" <?php if (!(strcmp("Opus 6", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 6</option>
              <option value="Opus 7" <?php if (!(strcmp("Opus 7", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 7</option>
              <option value="Opus 8" <?php if (!(strcmp("Opus 8", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 8</option>
              <option value="Opus 9" <?php if (!(strcmp("Opus 9", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 9</option>
              <option value="Opus 10" <?php if (!(strcmp("Opus 10", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 10</option>
              <option value="Opus 11" <?php if (!(strcmp("Opus 11", $row_rsGNupdate['works']))) {echo "selected=\"selected\"";} ?>>Opus 11</option>
          </select></td>
        </tr>
      </table>
      <p>&nbsp;</p>
      <p>
        <label for="entry">Text</label>
        <textarea id="entry" name="entry2"><?php echo $row_rsGNupdate['entry']; ?></textarea>
      </p>
    
      <p>
        <label for="comments">Comments</label>
        <textarea id="comments" name="comments"><?php echo $row_rsGNupdate['comments']; ?></textarea>
      </p>
      
      <p>
        <input type="submit" name="Insert" id="Insert" value="Submit" />
        <input name="id" type="hidden" id="id" value="<?php echo $row_rsGNupdate['id']; ?>" />
      </p>
<p>
  <input type="hidden" name="MM_update" value="form2" />
    </p>
    </form>
    <p>&nbsp;</p>
</div>
  </body>
</html>
<?php
mysql_free_result($rsGNupdate);
?>

Open in new window

0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 35749802
Okay, from the redirect code above ( http:#a35745020 ) you want to change line 4 like so:

$updateGoTo .= $_SERVER['QUERY_STRING'] ."#". $row_rsGNupdate['id'];

That should send you back to the correct anchor.
0
 

Author Comment

by:xtbarton
ID: 35750409
Sadly not; on the update page, the URL looks like update.php?id=1938#1938 and on the results page once an update is sumbitted the URL looks like results.php?id=1938# but it's not taking me to an anchor point.
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 2000 total points
ID: 35750426
Oops.  The update code happens before the recordset code.

Move lines 24-32 from that code snippet to above line 1
0
 

Author Comment

by:xtbarton
ID: 35750804
You're a genius.  Worked perfectly!

Thank you!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question