addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1light-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Pittsburgh PHP Developers Group Message Board › selecting and updating multiple rows

selecting and updating multiple rows

Hans W.
Pittsburgh, PA
Post #: 4
I am able to generate and display a selective list from a database. Using checkboxes, I want to select multiple rows to edit and submit the updates at the same time.

I have a page that I've been working based on an editing/updating page that works for individual rows. I've added parameters that involve counting the rows, for there is now some fundamental structure there that needs some serious tweaking.

I will admit that as an enthusiast, I'm surprised I've come as far as I have.

Hopefully, the solution is an easy fix. Anyone out there have experience with this? If so, I'd like to talk.

A former member
Post #: 6
I think this is what you're looking for.­ I believe there's a way to do it with pdo, but I haven't messed with it too much.
Hans W.
Pittsburgh, PA
Post #: 5
Thanks, I'll take a look at this and see what I can do. I expect that I will still need some help to actually get this done, through a mentor or a freelance consultant or otherwise.. If you have an leads for this, please shoot me an email.
Hans W.
Pittsburgh, PA
Post #: 6
Hi, after looking at this along with some continued searching on the web, what I am trying to do continues to elude me when attempting this on my own. I want to echo my interest in getting some assistance, either by way of mentoring or consulting.
A former member
Post #: 7
Take the example on the link that I posted previously, and change the mysql statement to be select statements for your tables. Save it into a test page. Then run them on your server, so you can see how it works. Once you do it one time you should have an understanding of how to do multiple queries in on pass. The trickiest part is the do statement. Everything else is fairly straight forward.
Hans W.
Pittsburgh, PA
Post #: 7
Thanks for responding. After some additional rooting around, I found a solution that is built on this piece of code:
<?php do { ?>

$sql = "SELECT * FROM dbtable ";

$foo = $_POST['id'];

if (count($foo) > 0) {

// loop through the array
for ($i=0;$i<count($foo);$i++) {

echo "<li>$foo[$i] \n";

} // end "for" loop


Worked like a charm.

I am now pushing this through 3 pages, the first to push a multiple selection of rows, the second to push a multiple select of rows to edit, but the second page only pushes the first id row, regardless which rows have been selected, and pushes only that to the third (edit) page.

the selection page has a preceding code that looks like this:

$query_admin1 = sprintf( 'SELECT * FROM dbtable WHERE id IN '.$updateprep.'' );

$admin1 = mysql_query($query_admin1, $conn1) or die(mysql_error());

$row_admin1 = mysql_fetch_assoc($admin1);

$totalRows_admin1 = mysql_num_rows($admin1);

$sql = $query_admin1;

$result2 = mysql_query($sql);

// Count table rows
$count = mysql_num_rows($result2);

$result = mysql_query($sql);

$i = 0;

while($rows = mysql_fetch_array($result2)){

After selecting the rows to be sent and submitting the form, it is followed by:

<?php } while($rows = mysql_fetch_array($result)) ?>
<?php } ?>

This works fine in the first page, but there is something that I am not identifying in the second page.

As you have been generous in replying, I felt it only proper to let you know how things have developed.


Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy