Page 1 of 1

problems deleting multiple rows

Posted: Tue Jul 30, 2002 3:24 pm
by fariquzeli
I've been trying to delete multiple rows from sql, I have a link on a seperate page that is passing the variable expire date. Now even when I set the variable to a normal page variable before doing the sql stuff, i still get nothing deleted. I echo out the variable and nothing appears, yet just above the code, I have a table echoing out all the accounts that contain the info in the column pertaining to expire_date

the code is rather long, but here is the entire thing:

Code: Select all

<?php
		  if (!$action) &#123;
		  ?>
		  <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">The 
              following accounts have expired this month, to delete them click 
              on the button below.</font></p>
            <form name="form1" method="post" action="<?=$PHP_SELF?>">
              <div align="center">
                <input type="submit" name="action" value="Delete Expired Accounts">
              </div>
            </form>
			<Br>
			<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#003300">
              <tr> 
                <td bgcolor="#F0FFE0"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Expiration 
                  Month</font></td>
                <td bgcolor="#F0FFE0"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Subscriber 
                  Name</font></td>
                <td bgcolor="#F0FFE0"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Account 
                  Username</font></td>
                <td bgcolor="#F0FFE0"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Email</font></td>
              </tr>
              <?php do &#123; ?>
              <tr bgcolor="#FFFFFF"> 
                <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_expired&#1111;'expire_date']; ?></font></td>
                <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_expired&#1111;'firstname']; ?> &nbsp;<?php echo $row_expired&#1111;'lastname']; ?></font></td>
                <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_expired&#1111;'username']; ?></font></td>
                <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><?php echo $row_expired&#1111;'email']; ?></font></td>
              </tr>
              <?php &#125; while ($row_expired = mysql_fetch_assoc($expired)); ?>
            </table>
			<?php
			&#125;
			else &#123;
			$sql = "DELETE FROM newsletterusers WHERE expire_date = '$expire_date'";
			$result = mysql_query($sql) or die(mysql_error());
			?><BR><BR><BR><BR>
			<p align="center"><font size="2" face="verdana, Arial, helvetica, sans-serif"><BR><BR><BR>The following accounts have expired and been deleted.</font><BR><BR><BR><a href="javascript:history.back()">Back to Admin Main</a></p><BR><BR><BR>
			<?php
			&#125;
			?>
the table in the middle echoes out all the accounts with the current expire_date, yet i can't delete them, any ideas?

Posted: Tue Jul 30, 2002 4:01 pm
by fariquzeli
aha, i've fixed it, the problem was I was re-submitting that page with a self-submitting form, and the variable being passed over to the new page wasn't being saved, I fixed the problem by making a hidden field that would echo out the passed variables.

simple as that! :)