How can I make a select all records that are "Pending" and update all to "Approved" when a button named "Approve all" is submitted? Is there actually a way to integrate your checkbox idea on all repeated regions of these records that will be specifically for each user?
Sorry for all the questions, but I'm trying to understand how i can actually make an admin section that will allow me to use repeated regions and make updating / deleting records as easy as possible..
THANKS FOR ALL THE HELP!
Here is my script:
//connect to database//
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($HTTP_GET_VARS['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $HTTP_GET_VARS['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_gspot, $gspot);
$query_Recordset1 = "SELECT * FROM membersrigs WHERE Status = 'Pending'";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $gspot) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($HTTP_GET_VARS['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $HTTP_GET_VARS['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
//approve user
$username = $row_Recordset1['Username'];
if ($_POST['approve']){
$shortlist = 'Approved';
$query2 = "UPDATE membersrigs SET Status='$shortlist' WHERE Username='$username'";
$result2 = mysql_query($query2) or die ("Error in query: $query2. " . mysql_error());
$msg = "Successfully Approved $username(s) record!";
header ("Location: /members/admin.php?msg=$msg");
}
//end approval
//start decline user
if ($_POST['decline']){
$result4 = mysql_query("SELECT vimage FROM membersrigs WHERE username = '$username'");
$vimage = mysql_fetch_assoc($result4);
$deletevimage = $vimage['vimage'];
$locvimage = "/webapp/vhosts/gspot@gspotracing.com/members/images/$deletevimage";
unlink($locvimage);
$query3 = "DELETE FROM membersrigs WHERE Username='$username'";
$result3 = mysql_query($query3) or die ("Error in query: $query3. " . mysql_error());
$msg = "You have successfully deleted $username(s) declined record";
header ("Location: /members/admin.php?msg=$msg");
}
//end decline
and the html:
<form name="form1" method="post" action="">
<input name="approve" type="submit" id="approve" value="Approve">
<input name="decline" type="submit" id="decline" value="Decline">
<span class="blue"><?php echo $row_Recordset1['Username']; ?>(s)</span> record?
</form>
<p class="greybold"><strong><font color="#FF0000">
<?php
if ($msg != "")
echo "<p>" . $msg;
?>
</font></strong></p>
<?php do { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%" class="blue"><div align="left">Username:</div></td>
<td width="80%"><div align="left"><?php echo $row_Recordset1['Username']; ?></div></td>
</tr>
<tr>
<td class="blue"><div align="left">Vehicle Make:</div></td>
<td><div align="left"><?php echo $row_Recordset1['Category']; ?></div></td>
</tr>
<tr>
<td class="blue"><div align="left">Vehicle Model:</div></td>
<td><?php echo $row_Recordset1['Vehicle Model']; ?> <div align="left"></div></td>
</tr>
<tr>
<td class="blue"><div align="left">Vehicle Year:</div></td>
<td><?php echo $row_Recordset1['Vehicle Year']; ?> <div align="left"></div></td>
</tr>
<tr>
<td class="blue"><div align="left">Modifications:</div></td>
<td><?php echo $row_Recordset1['Vehicle Modifications']; ?>
<div align="left"></div></td>
</tr>
<tr>
<td colspan="2"> <p align="left" class="blue">Vehicle Image:</p></td>
</tr>
<tr>
<td colspan="2"> <?php echo "<img src='" . "/members/images/" . $row_Recordset1['vimage'] . "'"; ?>
<div align="left"></div></td>
</tr>
<tr>
<td class="blue"><div align="left">Comments:</div></td>
<td><div align="left"><?php echo $row_Recordset1['Comments']; ?></div></td>
</tr>
<tr>
<td class="blue"><div align="left">Status:</div></td>
<td><div align="left"><?php echo $row_Recordset1['Status']; ?></div></td>
</tr>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>