-------------------------------- php------------------------------------- <?php $query_vsp_all = "SELECT * FROM vsp_admin WHERE vsp_coupon_sent = 1"; $vsp_all = mysql_query($query_vsp_all, $ppielogin) or die(mysql_error()); $row_vsp_all = mysql_fetch_assoc($vsp_all); $totalRows_vsp_all = mysql_num_rows($vsp_all); function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } if((isset($_POST[Submit_1])) && ($_POST[Submit_1] == "form1")) { while($row_vsp = mysql_fetch_assoc($vsp_all)) { $sql= sprintf("UPDATE vsp_admin SET vsp_coupon_redeemed = %s WHERE vsp_record_id = %s", GetSQLValueString(isset($_POST['redeemed_chkbx']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['vsp_record_id'], "int")); } mysql_query($sql) or die(mysql_error()); redirect_page('admin_vsp_view.php'); } ?> --------------------------------------------------html------------------------- <form name="form1" method="POST" > <table width="900" border="1"> <tr class="smallText" > <td colspan="13"><?php echo $totalRows_vsp_all ?> Records Total</td> </tr> <tr class="col_header"> <td>Coupon Number</td> <td>Sent</td> <td>Redeem</td> <td>Birthday Month</td> <td>First Name </td> <td>Last Name </td> <td>City</td> <td>Email</td> </tr> <?php do { ?> <tr class="smallText" > <td>0<?php echo $row_vsp_all['vsp_record_id']; ?> </td> <td> <input <?php if (!(strcmp($row_vsp_all['vsp_coupon_sent'],1))) {echo "checked=\"checked\"";} ?> name="sent_chkbx" type="checkbox" value="1" /></td> <td><input <?php if (!(strcmp($row_vsp_all['vsp_coupon_redeemed'],1))) {echo "checked=\"checked\"";} ?> name="redeemed_chkbx" type="checkbox" value="1" /> </td> <td><?php echo $row_vsp_all['vsp_birthday_month']; ?> </td> <td><?php echo ucfirst($row_vsp_all['vsp_firstname']); ?> </td> <td><?php echo ucfirst($row_vsp_all['vsp_lastname']); ?> </td> <td><?php echo ucfirst($row_vsp_all['vsp_city']); ?> </td> <td><?php echo strtolower($row_vsp_all['vsp_email']); ?> </td> </tr> <?php } while ($row_vsp_all = mysql_fetch_assoc($vsp_all)); ?> <tr> </tr> <input type="hidden" name="vsp_record_id" value="<?php echo $$row_vsp_all['vsp_record_id']; ?>"> </table><br /> <input type="hidden" name="Submit_1" value="form1"> <input type="submit" value="Update VSP Database" /> </form>
<?php mysql_select_db($database_ppielogin, $ppielogin); $query_vsp_all = "SELECT * FROM vsp_admin WHERE vsp_coupon_sent = 1"; $vsp_all = mysql_query($query_vsp_all, $ppielogin) or die(mysql_error()); $row_vsp_all = mysql_fetch_assoc($vsp_all); $totalRows_vsp_all = mysql_num_rows($vsp_all); ?> <?php function redirect_page($url) { header ('Location:' .$url); exit; } if ($totalRows_vsp_all = 0) { redirect_page('admin_vsp_view.php'); } ?> <?php // when the "update vsp database" button is clicked, insert a 1 to the vsp_coupon redeemed column in the vsp_admin table //UPDATE vsp_admin SET vsp_coupon_redeemed = 1 WHERE vsp_coupon_sent = 1 ||||| && $_POST['redeemed_chkbx'] == '1' function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } if((isset($_POST[Submit_1])) && ($_POST[Submit_1] == "form1")) { while($row_vsp = mysql_fetch_assoc($vsp_all)) { $sql= sprintf("UPDATE vsp_admin SET vsp_coupon_redeemed = %s WHERE vsp_record_id = %s", GetSQLValueString(isset($_POST['redeemed_chkbx']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['vsp_record_id'], "int")); } mysql_query($sql) or die(mysql_error()); redirect_page('admin_vsp_view.php'); } ?> ------------------------------------------------------------------------- <form name="form1" method="POST" > <table width="900" border="1"> <tr class="smallText" > <td colspan="13"><?php echo $totalRows_vsp_all ?> Records Total</td> </tr> <tr class="col_header"> <td>Coupon Number</td> <td>Sent</td> <td>Redeem</td> <td>Birthday Month</td> <td>First Name </td> <td>Last Name </td> <td>City</td> <td>Email</td> </tr> <?php do { ?> <tr class="smallText" > <td>0<?php echo $row_vsp_all['vsp_record_id']; ?> </td> <td> <input <?php if (!(strcmp($row_vsp_all['vsp_coupon_sent'],1))) {echo "checked=\"checked\"";} ?> name="sent_chkbx" type="checkbox" value="1" /></td> <td><input <?php if (!(strcmp($row_vsp_all['vsp_coupon_redeemed'],1))) {echo "checked=\"checked\"";} ?> name="redeemed_chkbx" type="checkbox" value="1" /> </td> <td><?php echo $row_vsp_all['vsp_birthday_month']; ?> </td> <td><?php echo ucfirst($row_vsp_all['vsp_firstname']); ?> </td> <td><?php echo ucfirst($row_vsp_all['vsp_lastname']); ?> </td> <td><?php echo ucfirst($row_vsp_all['vsp_city']); ?> </td> <td><?php echo strtolower($row_vsp_all['vsp_email']); ?> </td> </tr> <input type="hidden" name="vsp_record_id" value="<?php echo $row_vsp_all['vsp_record_id']; ?>"> <?php } while ($row_vsp_all = mysql_fetch_assoc($vsp_all)); ?> <tr> </tr> </table><br /> <input type="hidden" name="Submit_1" value="form1"> <input type="submit" value="Update VSP Database" /> </form>
<?php mysql_select_db($database_ppielogin, $ppielogin); $query_vsp_all = "SELECT * FROM vsp_admin WHERE vsp_coupon_sent = 1"; $vsp_all = mysql_query($query_vsp_all, $ppielogin) or die(mysql_error()); $row_vsp_all = mysql_fetch_assoc($vsp_all); $totalRows_vsp_all = mysql_num_rows($vsp_all); mysql_select_db($database_ppielogin, $ppielogin); $query_Recordset1 = "SELECT vsp_record_id FROM vsp_admin WHERE vsp_coupon_sent = 1"; $Recordset1 = mysql_query($query_Recordset1, $ppielogin) or die(mysql_error()); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <?php function redirect_page($url) { header ('Location:' .$url); exit; } if ($totalRows_vsp_all = 0) { redirect_page('admin_vsp_view.php'); } ?> <?php // when the "update vsp database" button is clicked, insert a 1 to the vsp_coupon redeemed column in the vsp_admin table //UPDATE vsp_admin SET vsp_coupon_redeemed = 1 WHERE vsp_coupon_sent = 1 ||||| && $_POST['redeemed_chkbx'] == '1' function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } if((isset($_POST[Submit_1])) && ($_POST[Submit_1] == "form1")) { while($row_Recordset1 = mysql_fetch_array($Recordset1)) { $sql= sprintf("UPDATE vsp_admin SET vsp_coupon_redeemed = %s WHERE vsp_record_id = %s", GetSQLValueString(isset($_POST['redeemed_chkbx']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['vsp_record_id'], "int")); } mysql_query($sql) or die(mysql_error()); redirect_page('admin_vsp_view.php'); } ?> ---------------------html---------------------- <h2>Redeem VSP Coupons</h2> <table width="900" border="1"> <tr class="smallText" > <td colspan="13"><?php echo $totalRows_Recordset1 ?> Records Total</td> </tr> <tr class="col_header"> <td>Coupon Number</td> <td>Sent</td> <td>Redeem</td> <td>Birthday Month</td> <td>First Name </td> <td>Last Name </td> <td>City</td> <td>Email</td> </tr> <form name="form1" method="POST" > <?php do { ?> <tr class="smallText" > <td>0<?php echo $row_vsp_all['vsp_record_id']; ?><input type="hidden" name="vsp_record_id" value="<?php echo $row_vsp_all['vsp_record_id']; ?>"> </td> <td> <input <?php if (!(strcmp($row_vsp_all['vsp_coupon_sent'],1))) {echo "checked=\"checked\"";} ?> name="sent_chkbx" type="checkbox" value="1" /></td> <td><input <?php if (!(strcmp($row_vsp_all['vsp_coupon_redeemed'],1))) {echo "checked=\"checked\"";} ?> name="redeemed_chkbx" type="checkbox" value="1" /> </td> <td><?php echo $row_vsp_all['vsp_birthday_month']; ?> </td> <td><?php echo ucfirst($row_vsp_all['vsp_firstname']); ?> </td> <td><?php echo ucfirst($row_vsp_all['vsp_lastname']); ?> </td> <td><?php echo ucfirst($row_vsp_all['vsp_city']); ?> </td> <td><?php echo strtolower($row_vsp_all['vsp_email']); ?> </td> </tr> <?php } while ($row_vsp_all = mysql_fetch_assoc($vsp_all)); ?> <input type="hidden" name="Submit_1" value="form1"> <input type="submit" value="Update VSP Database" /> </form> <tr> </tr> </table><br />
| DaniWeb Message | |
| Cancel Changes | |