RE: [PHP-DB] Help!!!
| From: | Juffermans, Jos | Date: | Thu, 19 May 2005 06:31:57 +0000 |
| Subject: | RE: [PHP-DB] Help!!! | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-39499@lists.php.net to get a copy of this message | ||
In the second loop you do an array_shift($entry) which should be
array_shift($all).
Perhaps a foreach loop would be easier:
<?php
foreach ($entry as $value) {
$update = "UPDATE accounts SET ctime=NOW() WHERE id_sys='" . $value.
"'";
$results = mysql_query($update, $Prod) or die(mysql_error());
}
foreach ($allas $value) {
$update = "UPDATE accounts SET ctime=NOW() WHERE id_sys='" . $value.
"'";
$results = mysql_query($update, $Prod) or die(mysql_error());
}
?>
Jos
-----Original Message-----
From: NIPP, SCOTT V (SBCSI) [mailto:sn4265@sbc.com]
Sent: 18 May 2005 22:47
To: php-db@lists.php.net
Subject: [PHP-DB] Help!!!
This is driving me absolutely nuts!!! I have a page that has
some checkboxes that will cause a database update for the selected
items. This page is a self referencing form page that never seems to
work. I have no idea what I am doing wrong. Here are the code portions
that I think are relevant.
This is the top of the page here:
<?php
while(isset($entry[0])) {
$redir = "set";
$tmp = $entry[0];
$update = "UPDATE accounts SET ctime=NOW() WHERE id_sys='".$tmp."'";
$results = mysql_query($update, $Prod) or die(mysql_error());
array_shift($entry);
}
while(isset($all[0])) {
$redir = "set";
$tmp = $all[0];
$update = "UPDATE accounts SET ctime=NOW() WHERE id_sys='".$tmp."'";
$results = mysql_query($update, $Prod) or die(mysql_error());
array_shift($entry);
}
if (isset($redir)) {
header('Location: link address');
}
$SBCUID = $_GET['SBCUID']; < This is the point at which some queries
build the page content
<<... Lots of stuff clipped ...>>
<Here is the guts of what builds the check
boxes. Everything displays properly>
<form method=post action="user_details.php">
<?php while ($list2 = mysql_fetch_assoc($requests_accounts)) {
$all[] = $list2['id_sys']; ?>
<tr bgcolor="#CCCCCC">
<td><div align="center"><?php echo $list2['system'];
?>
</div></td>
<td><div align="center"><?php echo $list2['gid'];
?>
</div></td>
<td><div align="center"><?php echo $list2['shell'];
?>
</div></td>
<td><div align="center"><?php echo $list2['rtime'];
?>
</div></td>
<td><div align="center"><?php echo $list2['atime'];
?>
</div></td>
<td><div align="center"><input name="entry[]" type=checkbox
value=<?php echo $list2['id_sys']; ?>></div></td>
</tr>
<?php } ;?>
</table>
<div align="center">
<input type=submit value="Update"><input name="all[]" type=submit
value="Update All">
</div>
</form>
The initial load of the page displays everything properly. The
problem is when I hit the "Update" or "Update All" buttons the page
reloads, but never actually makes it into the database update loops. I
cannot figure out what I am doing wrong here. I have used this kind of
code before and I am at a complete loss as to the problem. Please help
so I can actually get past this and onto some realy work. Thanks in
advance.
Scott Nipp
Phone: (214) 858-1289
E-mail: sn4265@sbc.com
Web: http:\\ldsa.sbcld.sbc.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php