PHP - Please Assist With Provide Discount Before Certain Date Only
I asked this once b4 and the answer seemed to work but now the discount is being caclulated again...I wanted the discount to stop after April 15...The below code doesn't work, can someone help???
Code: [Select] } if(date("j") < 14) { $before = $cost*.05; $before = round($before,2); $cost = $cost-$before; } Thank you in advance for ANY help that can be provided. Jennifer Similar TutorialsI finished making an entire php and it will not go to my SQL document. The problem is on line 1. Line 1 would be <?php . Anyway I will include the php here. Do you know what the problem is? Code: [Select] <?php //This gets all the other information from the form $Fname=$_POST['Fname']; $Lname=$_POST['Lname']; $Compname=$_POST['Compname']; $emailad=$_POST['emailad']; $urlname=$_POST['urlname']; $address=$_POST['address']; $address2=$_POST['address2']; $address3=$_POST['address3']; $phone=$_POST['phone']; $phone2=$_POST['phone2']; $phonename=$_POST['phonename']; $listingtype=$_POST['listingtype']; $formcheck1=$_POST['formcheck']['name']; $formcheck2=$_POST['formcheck']['name']; $formcheck3=$_POST['formcheck']['name']; $pic=($_FILES['photo']['name']); $pic2=($_FILES['photo']['name']); $pic3=($_FILES['photo']['name']); $pic4=($_FILES['photo']['name']); $description=$_POST['atDescription']; // Connects to your Database mysql_connect ("", "", "") or die(mysql_error()) ; mysql_select_db("") or die(mysql_error()) ; //Writes the photos to the server and store the names in $picname[] foreach ($_FILES["photo"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["photo"]["tmp_name"][$key]; $name = $_FILES["photo"]["name"][$key]; move_uploaded_file($tmp_name, "upload/$name"); $picname[] = $name; } else { //Gives and error if its not echo "bldf"; } } // setup empty names so that the variable will exist $pic = ""; $pic2 = ""; $pic3 = ""; $pic3 = ""; // overwrite the empty pic names if they exist if (count($picname) > 0) { //at least 1 pic $pic = $picname[0]; } if (count($picname) > 1) { //at least 2 pics $pic2 = $picname[1]; } if (count($picname) > 2) { //at least 3 pics $pic3 = $picname[2]; } if (count($picname) > 3) { //at least 4 pics $pic4 = $picname[3]; } // don't care if there's more than 4 //Writes the information to the database $sql = ("INSERT INTO bestform (Fname,Lname,Compname,emailad,urlname,address,address2,address3,phone,phone2,phonename,listingtype,formcheck_1,formcheck_2,formcheck_3,photo_1,photo_2,photo_3,photo_4,atDescription,) VALUES ('$Fname', '$Lname', '$Compname', '$emailad', '$urlname', '$address', '$address2', '$address3', '$phone', '$phone2', '$phonename', '$listingtype', '$formcheck1', '$formcheck2', '$formcheck3', '$pic', '$pic2', '$pic3', '$pic4', '$description')") ; //Writes the information to the database mysql_query($sql) or die(mysql_error()); // and catch any error echo date("m/d/y : H:i:s", time()) ?> Php Buddies, Line 67: $query = "SELECT page_url,link_anchor_text,page_description,keyphrases,keywords FROM links WHERE $_SESSION['search_column'] = ?"; I get error for the above:
How to fix this ?
Context: <?php //include('error_reporting.php'); ini_set('error_reporting','E_ALL');//Same as: error_reporting(E_ALL); ini_set('display_errors','1'); ini_set('display_startup_errors','1'); require('conn.php'); ?> <form name = "search" method = "POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label for="keywords">Keywords:*</label> <input type="text" name="keywords" id="keywords" placeholder="Input Keywords" required> <br> <label for="search_column">Search in ... ?</label> <select name="search_column" id="search_column"> <option value="page_url">Page Url</option> <option value="link_anchor_text">Link Anchor Text</option> <option value="page_description">Page Description</option> <option value="keyphrase">Keyphrase</option> <option value="keywords">Keywords</option> </select> <br> <label for="tos_agreement">Agree to TOS or not ? *</label> <select name="tos_agreement" id="tos_agreement" required> <option value="Yes">Yes</option> <option value="No">No</option> </select> <br> <input type="button" name="search_links" id="search_links" value="Search Links!"> <br> <input type="reset"> <br> </form> <?php if($_SERVER['REQUEST_METHOD'] === 'POST') { if(ISSET($_POST['search_links'])) { if(ISSET($_POST['page_url'])) { $_SESSION['search_column'] = $_POST['page_url']; } elseif(ISSET($_POST['link_anchor_text'])) { $_SESSION['search_column'] = $_POST['link_anchor_text']; } elseif(ISSET($_POST['page_description'])) { $_SESSION['search_column'] = $_POST['page_description']; } elseif(ISSET($_POST['keyphrase'])) { $_SESSION['search_column'] = $_POST['keyphrase']; } elseif(ISSET($_POST['keywords'])) { $_SESSION['search_column'] = $_POST['keywords']; } //Re-write the following 4 lines ... mysqli_report(MYSQLI_REPORT_ALL|MYSQLI_REPORT_STRICT); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $conn->set_charset('utf8mb4'); //Always set Charset. $query = "SELECT page_url,link_anchor_text,page_description,keyphrases,keywords FROM links WHERE $_SESSION['search_column'] = ?"; $stmt = mysqli_stmt_init($conn); if(mysqli_stmt_prepare($stmt,$query)) { mysqli_stmt_bind_param($stmt,'s',$_SESSION['search_column']); $result = mysqli_stmt_bind_result($stmt,$page_url,$link_anchor_text,$page_description,$keyphrase,$keywords); mysqli_stmt_execute($stmt); mysqli_stmt_fetch($stmt); while(mysqli_stmt_fetch($stmt)) { echo "url"; echo "<br>"; echo "anchor_text"; echo "<br>"; echo "description"; echo "<br>"; echo "keyphrases"; echo "<br>"; echo "keywords"; echo "<br>"; echo "|"; echo "<br>"; } mysqli_stmt_close($stmt); mysqli_close($conn); } else { echo "1. QUERY failed!"; } if(mysqli_stmt_prepare($stmt,$query)) { mysqli_stmt_bind_param($stmt,'sssss',$_POST['page_url'],$_POST['link_anchor_text'],$_POST['page_description'],$_POST['keyphrases'],$_POST['keywords']); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); while($row = mysqli_fetch_array($result,mysqli_assoc)) { $page_url = $row['page_url']; echo $page_url; echo "<br>"; $link_anchor_text = $row['link_anchor_text']; echo $link_anchor_text; echo "<br>"; $page_description = $row['page_description']; echo $page_description; echo "<br>"; $keyphrases = $row['keyphrases']; echo $keyphrases; echo "<br>"; $keywords = $row['keywords']; echo $keywords; echo "<br>"; echo "|"; echo "<br>"; } mysqli_stmt_close($stmt); mysqli_close($conn); } else { die("2. QUERY failed!"); } } } ?>Edited July 16, 2020 by 2020 Can someone provide me with a good tutorial on how to create really nice looking buttons please. Not just crap ones, like real nice ones. XD Thanks in advance i have a drop-down list of coures from course table. then i have two text field to enter No of Ques: Allocated Marks: for example: if i select PHP course and enter 4 for No of Ques , 25 for Allocated marks then it should srote in anothe database table like this Course | QuesNo | Marks PHP 1 25 PHP 2 25 PHP 3 25 PHP 4 25 Can anyone help for this code.hope this will not too dificult for you guys. i will really apriciate. Thanks Having to go into somebody else's code yet again! Gah! Originally the totaling page just subtracted a flat discount. But now the client wants to be able to subtract percentage discounts and 'per item' discounts. In the discount table I added a field to determine whether the discount chosen is to be applied as flat off total, flat per item, % off total, and % off each item. I also entered a field that can have a class id, in case this discount is only for that class. (the intention being that otherwise the discount is on anything) I've got a session variable that generates something like : Array ( [217] => 1 [215] => 2 ) meaning 1 person in class #217, and 2 people in class 215. $_SESSION['s_to_be_added'] = array_filter($_POST['participantqty']); Then on the page I'm concerned with, I've been trying to write the script. I know I still need some math stuff figured out But how do I take the array, do the math, and then generate an overall cost for the whole thing? and this is just the discounting? I don't even have a clue how to work in delimiting it if there's a class id.. did any of that make sense? Code: [Select] <?php // the above is the array I want to use to $passed_array = array_filter($_SESSION['s_to_be_added']); // this is the discount 'code' the user entered. $discount = mysql_escape_string($_POST['discount']); // just a donation added after everything. $donation = mysql_escape_string($_POST['donation']); // finding the discount that matches the discount 'code' entered. $query_selectAllItems_events = "SELECT discount_amount,discount_type,workshop_link_1 FROM tbl_discount where discount_value = '$discount'"; $result_all_events = mysql_query($query_selectAllItems_events); $numRows_all_events = mysql_num_rows($result_all_events); $num=mysql_num_rows($result_all_events); $z_row = mysql_fetch_array($result_all_events); // this is just a number: 1, 20, 90 etc. $discount_amount = $z_row['discount_amount']; /*this is 1,2,3,4 - for each type of discount 1- flat 2- flat per item 3- discount on all, 4- discount per item */ $discount_type = $z_row['discount_type']; // the workshop id if the discount is onlyh for this workshop $discount_link_1 = $z_row['workshop_link_1']; // just a description $discount_name = $z_row['discount_name']; if ($discount_type ==1) { /* flat discount on total here */ $total = mysql_escape_string($_POST['total']); $final_total = ($total - $discount_amount); $final_total = ($final_total + $donation); } elseif ($discount_type ==2)) { /* discount per item total here */ $total = mysql_escape_string($_POST['total']); $final_total = ($total - $discount_amount); $final_total = ($final_total + $donation); } elseif ($discount_type ==3)) { /* percentage discount on total here */ $total = mysql_escape_string($_POST['total']); $final_total = ($total * ($discount_amount/100)); $final_total = ($final_total + $donation); } elseif ($discount_type ==4)) { /* percentage discount per item here */ $total = mysql_escape_string($_POST['total']); $final_total = ($total * ($discount_amount/100)); $final_total = ($final_total + $donation); } ?> Hello,
I'm the sole developer of Aptugo (http://www.aptugo.com), a web RAD development environment with focus on making every developer's life easier. I've spent countless hours over the last two years developing it, and while the main focus is to be a CRUD boilerplate, it can actually build complete websites with great features (Aptugo's website was completely built with Aptugo, and google page insights gave me a score of 92 right out of the oven and without any effort).
Anyway, it would be really nice if you could spend a few minutes taking a look at Aptugo, It is free, and I really want to keep it free forever, in order to be able to achieve that, I really mouth-to-mouth promotion, so I'm not trying to sell you anything here, I'm just asking for help and your empathy! . If you could tell me: "I would use aptugo if it..." I would really appreciate it.
Have a great day,
Gaston
Hi, I am trying to figure out how to stop my script from offering a discount when the date that is listed passes by. It seems to always 'reset' itself even after the 15th of the month...I want it to stop after April 15...This is what I had, can anyone assist? Thank you in advance for your help! Jennifer Code: [Select] } if(date("n") < 15) { $before = $cost*.05; $before = round($before,2); $cost = $cost-$before; } Hey Guys, So I'm stuck on a particular line of PHP for woocommerce the code I have hear works for doing 2 levels of discount. 1 - The discount code in woocommerce coupon settings gives - 10% off for products in category named "10OFF" - Coupon settings are in the image below 2. This code here then allows the same coupon to give 15% off off products in category named "15OFF" 3. What I can't seem to work out, is how to add another layer to this, where the same coupon will give 35% off products in a category named "35OFF" I get the feeling this is something really super obvious to someone who knows more about PHP coding than myself! I've tried multiple IF statements, that breaks the whole thing. I'm confident Creating multiple Categories is the way forward. I just can't work out how to add the new categories to the code that doesn't suddenly break the whole thing again stopping all discounts being taken off each item. Any advice would be hugely appreciated! I know the Code could be a lot neater in general, but I'm really new to PHP Kind Regards to all Liam add_filter( 'woocommerce_coupon_get_discount_amount', 'alter_shop_coupon_data', 20, 5 ); function alter_shop_coupon_data( $round, $discounting_amount, $cart_item, $single, $coupon ){ //Settings// $coupon_codes = array('bigsavings'); // Product categories at 15% $product_category15 = array('15off'); // for 15% discount $second_percentage = 0.015; // 15 % // Code// if ( $coupon->is_type('percent') && in_array( $coupon->get_code(), $coupon_codes ) ) { if( has_term( $product_category15, 'product_cat', $cart_item['product_id'] ) ){ $original_coupon_amount = (float) $coupon->get_amount(); $discount = $original_coupon_amount * $second_percentage * $discounting_amount; $round = round( min( $discount, $discounting_amount ), wc_get_rounding_precision() ); } } return $round; }
Edited May 17 by liamhluk Additional info on what I've tried already I'm using the restrict content pro plugin to accept website registrations. I would like users to have the ability to click a checkbox on the registration page and it automatically applies a $50 discount. I am using this code to add a checkbox to the registration field, but I'm having trouble applying the "RCP_Discount" class when the box is checked. Any help would be greatly appreciated. Thank you! ~Sarah Hello,
I am not very good at javascript.
Actually i have form like this
<td> <input type="text" name="item[]" id="category" value="<?php echo $row1['item'];?>" /></td> <td> <input type="text" name="uom[]" class="span2" value="<?php echo $row1['uom'];?>" /></td> <td> <input type="text" name="description[]" value="<?php echo $row1['description'];?>" /></td> <td><input type="text" class="jQinv_item_qty span1" name="quantity[]" /></td> <td><input type="text" class="jQinv_item_unit span1" name="price[]" value="<?php echo $row1['selling_price'];?>" /></td> <td><select name="tax[]" class="jQinv_item_tax span1"> <option value="<?php echo $row1['tax'];?>"><?php echo $row1['tax'];?></option> <?php $l1 = mysql_query("select * from taxes") or die (mysql_error()); while($l2 = mysql_fetch_array($l1)) { ?> <option value="<?php echo $l2['rate']; ?>"> <?php echo $l2['name'];?> - <?php echo $l2['rate'];?>% </option> <?php } ?> </select></td> <td> <input type="text" class="jQinv_item_discount span1" name="discount[]" value="<?php echo $row1['discount'];?>" /></td> <td><input type="text" class="jQinv_item_frt span1" name="freight[]" placeholder="Freight" /></td> <td><input type="text" class="jQinv_item_frtax span1" name="freight_tax[]" placeholder="Frt Tax" /></td> <td><input type="text" class="jQinv_item_total span2" name="total[]" /></td> a =( ((Quantity * Price) - Discount) * (tax/100) ) + Freight + (Freight * (Freight tax/100))I tried doing like this, But it did not work at all function rowInputs() { var balance = 0; var subTotal = 0; var taxTotal = 0; $(".invE_table tr").not('.last_row').each(function () { var $unit_price = $('.jQinv_item_unit', this).val(); var $qty = $('.jQinv_item_qty', this).val(); var $tax = $('.jQinv_item_tax', this).val(); var $discount = $('.jQinv_item_discount', this).val(); var $frt = $('.jQinv_item_frt', this).val(); var $frtax = $('.jQinv_item_frtax', this).val(); var $total = (($unit_price * 1) * ($qty * 1))- $discount; var $tax_amount = (($total) *($tax/parseFloat("100"))); var $total_amount = (($tax_amount) + ($frt)) + $frtax; var parsedTotal = parseFloat( ('0' + $total_amount).replace(/[^0-9-\.]/g, ''), 10 ); var parsedTax = parseFloat( ('0' + $tax_amount).replace(/[^0-9-\.]/g, ''), 10 ); var parsedSubTotal = parseFloat( ('0' + $total).replace(/[^0-9-\.]/g, ''), 10 ); $('.jQinv_item_total',this).val(parsedTotal.toFixed(2)); subTotal += parsedSubTotal; taxTotal += parsedTax; balance += parsedTotal; }); var discount = parseFloat( ('0' + $('#inv_discount').val()).replace(/[^0-9-\.]/g, ''), 10 ); var balance_disc = balance - discount; $(".invE_subtotal span").html(subTotal.toFixed(2)); $(".invE_tax span").html(taxTotal.toFixed(2)); $(".invE_discount span").html(discount.toFixed(2)); $(".invE_balance span").html(balance_disc.toFixed(2)); } Hey, I'm using a script which allows you to click on a calendar to select the date to submit to the database. The date is submitted like this: 2014-02-08 Is there a really simple way to prevent rows showing if the date is in the past? Something like this: if($currentdate < 2014-02-08 || $currentdate == 2014-02-08) { } Thanks very much, Jack Dear All Good Day, i am new to PHP (a beautiful server side scripting language). i want to send a mail with line by line message i tried with different types like by placing the things in table and using <br /> but the thing is the tags are also visible in the message of the mail. Here is my code: $message1 = "Name :". $_REQUEST['name']."<br />"; $message1 .= "Surname :". $_REQUEST['surname']."<br />"; $message1 .= "Cellphone :". $_REQUEST['mobileno']."<br />"; $message1 .= "Telephone :". $_REQUEST['landno']."<br />"; $message1 .= "Fax :". $_REQUEST['fax']."<br />"; $message1 .= "Company :". $_REQUEST['company']."<br />"; $message1 .= "Email :". $_REQUEST['email']."<br />"; $message1 .= "Country :". $_REQUEST['country']."<br />"; $message1 .= "Enquity :". $_REQUEST['enquiry']."<br />"; $message1 .= "Date&Time :". $date."<br />"; For this code if try to print/echo it it is working fine it is displaying line by line, but using this variable ($message1) in the mail these <br /> are also visible. Can any one guide me to resolve(to remove these tags from the message part) this issue. Thanks in Advance. :confused: Hello. I'm new to pHp and I would like to know how to get my $date_posted to read as March 12, 2012, instead of 2012-12-03. Here is the code: Code: [Select] <?php $sql = " SELECT id, title, date_posted, summary FROM blog_posts ORDER BY date_posted ASC LIMIT 10 "; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; $title = $row['title']; $date_posted = $row['date_posted']; $summary = $row['summary']; echo "<h3>$title</h3>\n"; echo "<p>$date_posted</p>\n"; echo "<p>$summary</p>\n"; echo "<p><a href=\"post.php?id=$id\" title=\"Read More\">Read More...</a></p>\n"; } ?> I have tried the date() function but it always updates with the current time & date so I'm a little confused on how I get this to work. I have tried a large number of "solutions" to this but everytime I use them I see 0000-00-00 in my date field instead of the date even though I echoed and can see that the date looks correct. Here's where I'm at: I have a drop down for the month (1-12) and date fields (1-31) as well as a text input field for the year. Using the POST array, I have combined them into the xxxx-xx-xx format that I am using in my field as a date field in mysql. <code> $date_value =$_POST['year'].'-'.$_POST['month'].'-'.$_POST['day']; echo $date_value; </code> This outputs 2012-5-7 in my test echo but 0000-00-00 in the database. I have tried unsuccessfully to use in a numberof suggested versions of: strtotime() mktime Any help would be extremely appreciated. I am aware that I need to validate this data and insure that it is a valid date. That I'm okay with. I would like some help on getting it into the database. Alright, I have a Datetime field in my database which I'm trying to store information in. Here is my code to get my Datetime, however it's returning to me the wrong date. It's returning: 1969-12-31 19:00:00 $mysqldate = date( 'Y-m-d H:i:s', $phpdate ); $phpdate = strtotime( $mysqldate ); echo $mysqldate; Is there something wrong with it? (continuing from topic title) So if I set a date of July 7 2011 into my script, hard coded in, I would like the current date to be checked against the hard coded date, and return true if the current date is within a week leading up to the hard coded date. How could I go about doing this easily? I've been researching dates in php but I can't seem to work out the best way to achieve what I'm after. Cheers Denno Hi, I have a job listing website which displays the closing date of applications using: $expired_date (This displays a date such as 31st December 2019) I am trying to show a countdown/number of days left until the closing date. I have put this together, but I can't get it to show the number of days. <?php $expired_date = get_post_meta( $post->ID, '_job_expires', true ); $hide_expiration = get_post_meta( $post->ID, '_hide_expiration', true ); if(empty($hide_expiration )) { if(!empty($expired_date)) { ?> <span><?php echo date_i18n( get_option( 'date_format' ), strtotime( get_post_meta( $post->ID, '_job_expires', true ) ) ) ?></span> <?php $datetime1 = new DateTime($expired_date); $datetime2 = date('d'); $interval = $datetime1->diff($datetime2); echo $interval->d; ?> <?php } } ?> Can anyone help me with what I have wrong? Many thanks Hi there, I have a string '12/04/1990', that's in the format dd/mm/yyyy. I'm attempting to convert that string to a Date, and then insert that date into a MySQL DATE field. The problem is, every time I try to do so, I keep getting values like this in the database: 1970-01-01. Any ideas? Much appreciated. i have a table that shows payments made but want to the payments only showing from a set date(06/12/14) and before this date i dont want to show
this is my sql that doesnt seem to work and is showing dates before the specified date.
.
"SELECT * FROM payments2014, signup2014, editprop2014 WHERE signup2014.userid = payments2014.payment_userid AND editprop2014.prop_id = signup2014.prop_id AND signup2014.userid !='page1' AND signup2014.userid !='page6' AND signup2014.userid !='page4' AND payments2014.payment_transaction_status !='none' AND payments2014.payment_transaction_status !='CANCELLEDa' AND payments2014.payment_type !='deposit' AND payments2014.payment_paid_timestamp NOT LIKE '%2012%' AND payments2014.payment_paid_timestamp NOT LIKE '%2011%' AND payments2014.payment_paid_timestamp >= '06/12/14' ORDER BY payments2014.payment_id DESC"i have some other parts in the statment but this one that should be filtering is host_payments2014.payment_paid_timestamp >= '06/12/14'thanks in advance Hi guys, I'm putting together a small event system where I want the user to add his own date and time into a textfield (I'll probably make this a series of drop-downs/a date picker later). This is then stored as a timestamp - "0000-00-00 00:00:00" which displays fine until I try to echo it out as a UK date in this format - jS F Y, which just gives today's date but not the inputted date. Here's the code I have right now: Code: [Select] $result = mysql_query("SELECT * FROM stuff.events ORDER BY eventdate ASC"); echo "<br />"; echo mysql_result($result, $i, 'eventvenue'); echo ", "; $dt = new DateTime($eventdate); echo $dt->format("jS F Y"); In my mysql table eventdate is set up as follows: field - eventdate type - timestamp length/values - blank default - current_timestamp collation - blank attributes - on update CURRENT_TIMESTAMP null - blank auto_increment - blank Any help as to why this could be happening would be much appreciated, thanks. |