Tuesday, January 21, 2020

CSV data attachment using PHP Mysqli

This summary is not available. Please click here to view the post.

Delete table data using ajax file php Mysqli

<span id="new_select2" style="color:green;text-align:center;font-weight:bold;"></span> // Show div

  onchange="fetch_select2(this.value);"  //Click Function

<script type="text/javascript">
function fetch_select2(val)
{
$.ajax({
type: 'post',
url: 'https://sasnagar.co.in/ezboxes//wp-content/themes/Divi/delete_calender_date.php?del_id=<?php $del_date_id= $row_pack["id"]; echo $del_date_id; ?>',
data: {
 get_option1:val
},
success: function (response) {
 document.getElementById("new_select2").innerHTML=response;
}
});
}
$('#new_select2').delay(5000).fadeOut('slow');
</script>

Thursday, January 16, 2020

Price show in decimal using PHP

<?php echo number_format((float)$total_ct_sum, 2, '.', ''); ?>

Single digit add 0 using PHP :
<?php $num_month = sprintf("%02d", $day_01); ?>

Thursday, January 9, 2020

Get database record using month and year PHP MYSQLI

<table id="example" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
            <th colspan="2" class="tble_fb">Calender</th>
            <th colspan="1" class="tble_fb">Order #</th>
            <th colspan="1" class="tble_fb">Order Status</th>
            <th colspan="5" class="tble_fb">Contact Info</th>
            <th colspan="3" class="tble_fb">Item Info</th>
            <th colspan="3" class="tble_fb">Rent Period</th>
            <th colspan="4" class="tble_fb">Delivery Info</th>
            <th colspan="4" class="tble_fb">Pick Up Info</th>
            <th colspan="1" class="tble_fb">Order Notes</th>
        </tr>
<tr>                     
    <td class="heading_cls">Date</td>
    <td class="heading_cls">Day</td>
    <td class="heading_cls">Order #</td>
    <td class="heading_cls">New Order</td>
        <td class="heading_cls">First Name</td>
        <td class="heading_cls">Last Name</td>
        <td class="heading_cls">Email</td>
        <td class="heading_cls">Phone</td>
        <td class="heading_cls">Secondary Phone</td>
        <td class="heading_cls">Package</td>
        <td class="heading_cls">Package Boxes</td>
        <td class="heading_cls">Added Items</td>
        <td class="heading_cls">Rent Period</td>
        <td class="heading_cls">Rent Extra Week(s)</td>
        <td class="heading_cls">Delivery Date</td>
        <td class="heading_cls">Delivery Address</td>
        <td class="heading_cls">Delivery Apt</td>
        <td class="heading_cls">Stair/Elevator</td>
        <td class="heading_cls">Pick Up Date</td>
        <td class="heading_cls">Pick Up Address</td>
        <td class="heading_cls">Pick Up Apt</td>
        <td class="heading_cls">Stair/Elevator</td>
        <td class="heading_cls">Order Notes</td>
        </tr>
</thead> 
    <tbody>
<?php
$servername = "localhost";
$username = "xxxxx";
$password = "xxxx(*()";
$dbname = "xxxx";
date_default_timezone_set('Canada/Eastern');
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

@$month_year=$_REQUEST['month_year'];
if(@$_POST['cal_dat_get']){
$startdate = date("m/d/Y", strtotime($month_year));

}else{
$startdate =  date("m/d/Y");
}
$exp = explode('/', $startdate);
$year = $exp[2];
$month = $exp[0];
$day_01 = '01';

   for($day_01='01';$day_01<='31';$day_01++){
   $tada_01 = $month.'/'.$day_01.'/'.$year;
   if(@$_POST['cal_dat_get']){  
$sql_package = "SELECT * from xxxx WHERE payment_status='succeeded' AND (order_status_type='New Order' OR order_status_type='Delivered') and order_date like '%$tada_01%' order by id desc";
   }else{
   $sql_package = "SELECT * from xxxxx WHERE payment_status='succeeded' AND (order_status_type='New Order' OR order_status_type='Delivered') and order_date like '%$tada_01%' order by id desc";
   }


$result = $conn->query($sql_package);

$val_price = 0;

if ($result->num_rows > 0) {
    while($row_pack = $result->fetch_assoc()) {
?>
<tr>                     
   
 
        <td class="heading_cls"><?php echo $row_pack["first_name"]; ?></td>
        <td class="heading_cls"><?php echo $row_pack["last_name"]; ?></td>
        <td class="heading_cls"><?php echo $row_pack["email_personal"]; ?></td>
        <td class="heading_cls"><?php echo $row_pack["phone_number1"]; ?></td>
        </tr>
 
<?php
    }
} else {
    ?>
<tr>                     
        <td class="heading_cls" style="border-right: none;"></td>
        <td class="heading_cls" style="border-right: none;"></td>
        <td class="heading_cls" style="border-right: none;"></td>
        <td class="heading_cls" style="border-right: none;"></td>
        <td class="heading_cls"></td>
        </tr>
<?php

}
  }
?> </tbody>
</table>

Get Weekly data using PHP MYSQLI

<table id="example" class="table table-striped table-bordered wely_tableset" style="width:100%">
<thead> 
<tr>
            <th style="line-height: 20px;border-right-color: #000;" colspan="2" class="tble_fb">For the week of Tuesday:</th>
            <th style="line-height: 50px;border-right-color: #000;" colspan="2" class="tble_fb"><?php date_default_timezone_set('Canada/Eastern'); $tuesday_date = date("m/d/Y", strtotime("previous tuesday"));
//echo $tuesday_date; echo '***';
$past_tuesday = date("d-M-Y", strtotime( "$tuesday_date -7 day" ) );
echo $past_tuesday; ?></th>
            <th colspan="2" style="border-right-color: #000;" class="tble_fb sdfrds">To Tuesday:
<span class="tblspn">Items Info</span>
</th>
            <th style="" colspan="3" class="tble_fb sdfrds"><?php  $tuesday_date = date("d-M-Y", strtotime("previous tuesday"));
echo $tuesday_date;
 ?>
<span class="tblspn">Payment Info</span>
</th>
        </tr>
<tr>                     
    <td class="heading_cls">Order Id</td>
        <td class="heading_cls">Order Status</td>
        <td class="heading_cls">Refer By</td>
    </tr>
</thead>
<tbody>
<?php
$servername = "localhost";
$username = "xxxx";
$password = "xxxx(*()";
$dbname = "xxxx";
date_default_timezone_set('Canada/Eastern');
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
  $start_date_week = new DateTime('-7');
  $current_date_week = $start_date_week->format('m/d/Y');
  //echo $current_date_week;echo '****';
  $dt = date("m/d/Y");
  $day_date_future = date("m/d/Y", strtotime( "$dt -7 day" ) );
 //echo $day_date;die('hhhhhhhhhhh');

 $tuesday_date = date("m/d/Y", strtotime("previous tuesday"));
//echo $tuesday_date; echo '***';
$past_tuesday = date("m/d/Y", strtotime( "$tuesday_date -7 day" ) );
//echo $past_tuesday;
 
$sql_package = "SELECT * from xxxxx WHERE order_status_type='Completed' AND order_complete_date and ('$past_tuesday' AND '$tuesday_date') order by id";


$result = $conn->query($sql_package);

$val_price = 0;

if ($result->num_rows > 0) {
    while($row_pack = $result->fetch_assoc()) {
?>
<tr>                     
    <td class="heading_cls size_sett"><?php $order_id_pac = $row_pack["order_id"];echo $order_id_pac; ?></td>
        <td class="heading_cls" style="background:#c6e0b3;"><?php echo $row_pack["order_status_type"]; ?></td>
        <td class="heading_cls size_sett"><?php echo '$'.$row_pack["package_total"]; $val_price += $row_pack["package_total"];?></td>
    </tr>
<?php
    }
} else {
   // echo "0 results";
}
?>
 <tr>

<td style="border-left: none !important;border-right: none !important;font-size:0px;">Total</td>
<td style="font-weight:bold;">Total</td>
<td style="font-weight:bold">$<?php echo number_format($val_price); ?></td>
</tr>
</tbody>

</table>