Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

OT: How do I update many records in on swoop?

LEGEND ,
Mar 03, 2007 Mar 03, 2007
I have a list of about 400 items, and I need to manage that list by changing
some of them. To do this a record at a time would be tedious. How can I
edit - say - 30 at a time, and then update them all with a single submit?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



TOPICS
Server side applications
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 03, 2007 Mar 03, 2007
What language and DB are you using?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2007 Mar 04, 2007
PHP and MySQL.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"envision3d" <webforumsuser@macromedia.com> wrote in message
news:esdmpv$nih$1@forums.macromedia.com...
> What language and DB are you using?


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2007 Mar 04, 2007
Murray,

Tom Muck has an article on how to do this published at Community MX if you
happen to be a member http://www.communitymx.com/abstract.cfm?cid=01723 if
your not it will cost you $4 :-)

--
Dave Buchholz
I-CRE8
www.i-cre8.co.uk
Skype ID: I-CRE8



"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:eseg2v$eib$1@forums.macromedia.com...
> PHP and MySQL.
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "envision3d" <webforumsuser@macromedia.com> wrote in message
> news:esdmpv$nih$1@forums.macromedia.com...
>> What language and DB are you using?
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2007 Mar 04, 2007
Thanks, Dave. I'm not, but it's affordable.... 8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Dave Buchholz" <forums@REMOVETHISi-cre8.co.uk> wrote in message
news:eseljj$jaf$1@forums.macromedia.com...
> Murray,
>
> Tom Muck has an article on how to do this published at Community MX if you
> happen to be a member http://www.communitymx.com/abstract.cfm?cid=01723 if
> your not it will cost you $4 :-)
>
> --
> Dave Buchholz
> I-CRE8
> www.i-cre8.co.uk
> Skype ID: I-CRE8
>
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:eseg2v$eib$1@forums.macromedia.com...
>> PHP and MySQL.
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>> "envision3d" <webforumsuser@macromedia.com> wrote in message
>> news:esdmpv$nih$1@forums.macromedia.com...
>>> What language and DB are you using?
>>
>>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2007 Mar 04, 2007
On 03 Mar 2007 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> I have a list of about 400 items, and I need to manage that list by
> changing some of them. To do this a record at a time would be
> tedious. How can I edit - say - 30 at a time, and then update them
> all with a single submit?

More details, like is it the same or similar change to all records? Or
is there something in common with all the records which need to be
changed, so that you could select them?

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2007 Mar 04, 2007
The change would be to a single field in all of the records - just a toggle
from true to false.

And, it happens to be to ALL the records in that table.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns98E99CEAF95CFmakowiecatnycapdotrE@216.104.212.96...
> On 03 Mar 2007 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:
>
>> I have a list of about 400 items, and I need to manage that list by
>> changing some of them. To do this a record at a time would be
>> tedious. How can I edit - say - 30 at a time, and then update them
>> all with a single submit?
>
> More details, like is it the same or similar change to all records? Or
> is there something in common with all the records which need to be
> changed, so that you could select them?
>
> --
> Joe Makowiec
> http://makowiec.net/
> Email: http://makowiec.net/email.php


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2007 Mar 04, 2007
On Sun, 4 Mar 2007 16:48:53 -0500, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>The change would be to a single field in all of the records - just a toggle
>from true to false.
>
>And, it happens to be to ALL the records in that table.

From true to false? What is the field type? One quick query should do
it. If it's a string using "true" or "false" you could do it with:

mysql_query("UPDATE yourtable SET fieldname='false'");

Gary
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2007 Mar 04, 2007
On 04 Mar 2007 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> The change would be to a single field in all of the records - just a
> toggle from true to false.
>
> And, it happens to be to ALL the records in that table.

In addition to Gary's response, without looking, PHPMyAdmin should have
something like that built in. OK, I looked, and it doesn't, but you can
enter SQL directly.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2007 Mar 04, 2007
This is something I want the client to be able to do, and although I said to
all what I meant was that all records would be candidates for the change but
maybe only 20 of them would actually change. What I'm trying to avoid is
the true->false, then update, and repeat thing.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns98E9C408E8EB0makowiecatnycapdotrE@216.104.212.96...
> On 04 Mar 2007 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:
>
>> The change would be to a single field in all of the records - just a
>> toggle from true to false.
>>
>> And, it happens to be to ALL the records in that table.
>
> In addition to Gary's response, without looking, PHPMyAdmin should have
> something like that built in. OK, I looked, and it doesn't, but you can
> enter SQL directly.
>
> --
> Joe Makowiec
> http://makowiec.net/
> Email: http://makowiec.net/email.php


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2007 Mar 04, 2007
On 04 Mar 2007 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> This is something I want the client to be able to do, and although I
> said to all what I meant was that all records would be candidates
> for the change but maybe only 20 of them would actually change.
> What I'm trying to avoid is the true->false, then update, and repeat
> thing.

A DW 'Update Recordset' behavior, 20-30/page, checkbox for 'update this
record', 'Next Page »' link, ...

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2007 Mar 05, 2007
Murray *ACE* wrote:
> This is something I want the client to be able to do, and although I said to
> all what I meant was that all records would be candidates for the change but
> maybe only 20 of them would actually change. What I'm trying to avoid is
> the true->false, then update, and repeat thing.

Come on, Murray, make up your mind.

Without knowing the full details of what you (or the client) actually
want, it's difficult to give an optimal answer. However, it's relatively
simple to do what you want.

1. Create a recordset of the target records.
2. Create a single-row table in a form. Inside the single row, put a
checkbox with the name toggle[] and set its value to the primary ID of
the record. Also display something that the client can recognize the
record by.
3. Apply a repeat region to the row, so that all records are displayed.
4. Add a submit button to the form.
5. Apply an update record server behavior. It doesn't really matter what
you update, because you then need to dive into code view to edit it.
6. Edit the update record server behavior so that it includes the following:

if (isset($_POST['toggle']) && is_array($_POST['toggle'])) {
$toggle = implode(',', $_POST['toggle']);
}
else {
$toggle = NULL;
}

7. Set the update SQL to this:
$sql = "UPDATE myTable SET column = 'false'
WHERE primary_key IN ($toggle)";

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2007 Mar 05, 2007
> Come on, Murray, make up your mind.

I'm trying, but nothing's happening! 8)

I thought this was what I was explaining all along.

Look - here's the page -

http://66.165.80.209/edit-districts.php

There are 400 of those suckers, give or take. I would like for the client
to be able to update a page at a time rather than a record at a time. Even
so, it's a tedious job.

Looks like your solution below will do that for me.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:esgqi9$l3m$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> This is something I want the client to be able to do, and although I said
>> to all what I meant was that all records would be candidates for the
>> change but maybe only 20 of them would actually change. What I'm trying
>> to avoid is the true->false, then update, and repeat thing.
>
> Come on, Murray, make up your mind.
>
> Without knowing the full details of what you (or the client) actually
> want, it's difficult to give an optimal answer. However, it's relatively
> simple to do what you want.
>
> 1. Create a recordset of the target records.
> 2. Create a single-row table in a form. Inside the single row, put a
> checkbox with the name toggle[] and set its value to the primary ID of the
> record. Also display something that the client can recognize the record
> by.
> 3. Apply a repeat region to the row, so that all records are displayed.
> 4. Add a submit button to the form.
> 5. Apply an update record server behavior. It doesn't really matter what
> you update, because you then need to dive into code view to edit it.
> 6. Edit the update record server behavior so that it includes the
> following:
>
> if (isset($_POST['toggle']) && is_array($_POST['toggle'])) {
> $toggle = implode(',', $_POST['toggle']);
> }
> else {
> $toggle = NULL;
> }
>
> 7. Set the update SQL to this:
> $sql = "UPDATE myTable SET column = 'false'
> WHERE primary_key IN ($toggle)";
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2007 Mar 05, 2007
This is on the page -

<tr>
<td><?php echo $row_rsDistricts['distName']; ?></td>
<td align="center"><select name="distDisplay" size="1"
id="distDisplay">
<option value="0"<?php echo
!$row_rsDistricts['distDisplay']?' selected="selected"':'' ?>>NO</option>
<option value="1"<?php echo
$row_rsDistricts['distDisplay']?' selected="selected"':'' ?>>YES</option>
</select>
<input name="distRecNum" type="hidden" id="distRecNum"
value="<?php echo $row_rsDistricts['distRecNum']; ?>" /></td>
</tr>


And I have this after applying the SB -

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

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE cma_districts SET distDisplay=%s WHERE
distRecNum=%s",
GetSQLValueString($_POST['distDisplay'], "int"),
GetSQLValueString($_POST['distRecNum'], "int"));

mysql_select_db($database_cmaConn, $cmaConn);
$Result1 = mysql_query($updateSQL, $cmaConn) or die(mysql_error());
}

and I'm changing it to this -

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

if (isset($_POST['distDisplay']) && is_array($_POST['distDisplay'])) {
$toggle = implode(',', $_POST['distDisplay']);
}
else {
$toggle = NULL;
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE cma_districts SET distDisplay=%s WHERE
distRecNum=%s",
GetSQLValueString($_POST['distDisplay'], "int"),
GetSQLValueString($_POST['distRecNum'], "int"));

mysql_select_db($database_cmaConn, $cmaConn);
$Result1 = mysql_query($updateSQL, $cmaConn) or die(mysql_error());
}

How would I adjust the SQL under these conditions?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:esgqi9$l3m$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> This is something I want the client to be able to do, and although I said
>> to all what I meant was that all records would be candidates for the
>> change but maybe only 20 of them would actually change. What I'm trying
>> to avoid is the true->false, then update, and repeat thing.
>
> Come on, Murray, make up your mind.
>
> Without knowing the full details of what you (or the client) actually
> want, it's difficult to give an optimal answer. However, it's relatively
> simple to do what you want.
>
> 1. Create a recordset of the target records.
> 2. Create a single-row table in a form. Inside the single row, put a
> checkbox with the name toggle[] and set its value to the primary ID of the
> record. Also display something that the client can recognize the record
> by.
> 3. Apply a repeat region to the row, so that all records are displayed.
> 4. Add a submit button to the form.
> 5. Apply an update record server behavior. It doesn't really matter what
> you update, because you then need to dive into code view to edit it.
> 6. Edit the update record server behavior so that it includes the
> following:
>
> if (isset($_POST['toggle']) && is_array($_POST['toggle'])) {
> $toggle = implode(',', $_POST['toggle']);
> }
> else {
> $toggle = NULL;
> }
>
> 7. Set the update SQL to this:
> $sql = "UPDATE myTable SET column = 'false'
> WHERE primary_key IN ($toggle)";
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2007 Mar 05, 2007
Murray *ACE* wrote:
> This is on the page -

Put this before the repeat region:

<?php $counter = 1; ?>

Change the repeat region to this:

<tr>
<td><?php echo $row_rsDistricts['distName']; ?></td>
<td align="center"><select name="distDisplay[]" size="1"
id="distDisplay<?php echo $counter; ?>">
<option value="0"<?php echo
!$row_rsDistricts['distDisplay']?' selected="selected"':'' ?>>NO</option>
<option value="1"<?php echo
$row_rsDistricts['distDisplay']?' selected="selected"':'' ?>>YES</option>
</select>
<input name="distRecNum[]" type="hidden"
id="distRecNum<?php echo $counter++; ?>"
value="<?php echo $row_rsDistricts['distRecNum']; ?>" /></td>
</tr>


> And I have this after applying the SB -
>
> $editFormAction = $_SERVER['PHP_SELF'];
> if (isset($_SERVER['QUERY_STRING'])) {
> $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
> }
>
> if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
> $updateSQL = sprintf("UPDATE cma_districts SET distDisplay=%s WHERE
> distRecNum=%s",
> GetSQLValueString($_POST['distDisplay'], "int"),
> GetSQLValueString($_POST['distRecNum'], "int"));
>
> mysql_select_db($database_cmaConn, $cmaConn);
> $Result1 = mysql_query($updateSQL, $cmaConn) or die(mysql_error());
> }

Change it to this:

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

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {

if (isset($_POST['distDisplay']) && is_array($_POST['distDisplay']) &&
isset($_POST['distRecNum']) && is_array($_POST['distRecNum'])) {

for ($i = 0; $i < count($_POST['distDisplay']); $i++) {

$updateSQL = sprintf("UPDATE cma_districts SET distDisplay=%s WHERE
distRecNum=%s",
GetSQLValueString($_POST['distDisplay'][$i], "int"),
GetSQLValueString($_POST['distRecNum'][$i], "int"));

mysql_select_db($database_cmaConn, $cmaConn);
$Result1 = mysql_query($updateSQL, $cmaConn) or die(mysql_error());
}
else {
echo 'Error: update parameters invalid';
}
}

I haven't tested it, but the code looks as though it should do the business.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2007 Mar 05, 2007
Thank you, David! Beautiful

I have this now -

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
if (isset($_POST['distDisplay']) && is_array($_POST['distDisplay']) &&
isset($_POST['distRecNum']) && is_array($_POST['distRecNum'])) {

for ($i = 0; $i < count($_POST['distDisplay']); $i++) {

$updateSQL = sprintf("UPDATE cma_districts SET distDisplay=%s WHERE
distRecNum=%s",
GetSQLValueString($_POST['distDisplay'][$i], "int"),
GetSQLValueString($_POST['distRecNum'][$i], "int"));

mysql_select_db($database_cmaConn, $cmaConn);
$Result1 = mysql_query($updateSQL, $cmaConn) or die(mysql_error());
}
} else {
echo 'Error: update parameters invalid';
}
}

Note the extra "}" required before the else.

It seems to work nicely....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:eshkdk$g7m$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> This is on the page -
>
> Put this before the repeat region:
>
> <?php $counter = 1; ?>
>
> Change the repeat region to this:
>
> <tr>
> <td><?php echo $row_rsDistricts['distName']; ?></td>
> <td align="center"><select name="distDisplay[]" size="1"
> id="distDisplay<?php echo $counter; ?>">
> <option value="0"<?php echo
> !$row_rsDistricts['distDisplay']?' selected="selected"':'' ?>>NO</option>
> <option value="1"<?php echo
> $row_rsDistricts['distDisplay']?' selected="selected"':'' ?>>YES</option>
> </select>
> <input name="distRecNum[]" type="hidden"
> id="distRecNum<?php echo $counter++; ?>"
> value="<?php echo $row_rsDistricts['distRecNum']; ?>" /></td>
> </tr>
>
>
>> And I have this after applying the SB -
>>
>> $editFormAction = $_SERVER['PHP_SELF'];
>> if (isset($_SERVER['QUERY_STRING'])) {
>> $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
>> }
>>
>> if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
>> $updateSQL = sprintf("UPDATE cma_districts SET distDisplay=%s WHERE
>> distRecNum=%s",
>> GetSQLValueString($_POST['distDisplay'], "int"),
>> GetSQLValueString($_POST['distRecNum'], "int"));
>>
>> mysql_select_db($database_cmaConn, $cmaConn);
>> $Result1 = mysql_query($updateSQL, $cmaConn) or die(mysql_error());
>> }
>
> Change it to this:
>
> $editFormAction = $_SERVER['PHP_SELF'];
> if (isset($_SERVER['QUERY_STRING'])) {
> $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
> }
>
> if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
>
> if (isset($_POST['distDisplay']) && is_array($_POST['distDisplay']) &&
> isset($_POST['distRecNum']) && is_array($_POST['distRecNum'])) {
>
> for ($i = 0; $i < count($_POST['distDisplay']); $i++) {
>
> $updateSQL = sprintf("UPDATE cma_districts SET distDisplay=%s WHERE
> distRecNum=%s",
> GetSQLValueString($_POST['distDisplay'][$i],
> "int"),
> GetSQLValueString($_POST['distRecNum'][$i],
> "int"));
>
> mysql_select_db($database_cmaConn, $cmaConn);
> $Result1 = mysql_query($updateSQL, $cmaConn) or die(mysql_error());
> }
> else {
> echo 'Error: update parameters invalid';
> }
> }
>
> I haven't tested it, but the code looks as though it should do the
> business.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2007 Mar 05, 2007
Murray *ACE* wrote:
> Thank you, David! Beautiful

Good.

> Note the extra "}" required before the else.

I just left that out to test you. :-p

That's why Balance braces is such a godsend.

Just one minor change. Move this line:

mysql_select_db($database_cmaConn, $cmaConn);

Put it directly above this one:

for ($i = 0; $i < count($_POST['distDisplay']); $i++) {

There's no need to select the database on every iteration of the loop,
since you're using the same one every time.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2007 Mar 05, 2007
LATEST
> I just left that out to test you. :-p
>
> That's why Balance braces is such a godsend.

No kidding - counting braces is mind-numbing.

> There's no need to select the database on every iteration of the loop,
> since you're using the same one every time.

Right - good suggestion!

Thanks again,

Murray

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:eshrcs$mkr$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Thank you, David! Beautiful
>
> Good.
>
>> Note the extra "}" required before the else.
>
> I just left that out to test you. :-p
>
> That's why Balance braces is such a godsend.
>
> Just one minor change. Move this line:
>
> mysql_select_db($database_cmaConn, $cmaConn);
>
> Put it directly above this one:
>
> for ($i = 0; $i < count($_POST['distDisplay']); $i++) {
>
> There's no need to select the database on every iteration of the loop,
> since you're using the same one every time.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines