Jump to content

sashavalentina

Members
  • Posts

    43
  • Joined

  • Last visited

Everything posted by sashavalentina

  1. Fatal error: Uncaught Error: Call to undefined method MongoDB\Driver\Manager::listDatabases() this error keep showing when i wanted to use the administration command for mongodb using php. I do not know whats the problem here and someone with kind soul please help me. The following codes is what i have tried which cause that error. <?php $client = new MongoDB\Driver\Manager( 'mongodb+srv://'.$_ENV['MDB_USER'].':'.$_ENV['MDB_PASS'].'@'.$_ENV['ATLAS_CLUSTER_SRV'].'/test' ); try{ $dbs = $client->listDatabases(); echo '<pre>'; print_r($dbs); echo '</pre>'; // Or Nothing if you just wanna check for errors } catch(Exception $e){ echo "Unable to connect to Database at the moment ! "; exit(); } $colecciones = $client->listCollections(); foreach ($colecciones as $col) { echo $col->getName(); } ?> what i am trying to do here is to make sure that my database connection is successful and also list out the collection name of my mongodb database.
  2. I have four different locations that is displayed from a set of arrays of coordinates. I'd like to change the shown location in my Google Map by click on the buttons that are coordinated. I tried to use a Javascript function with setCenter(), but unfortunately it doesn't work. Has anyone an idea what might be wrong? i checked it in inspection mode, and i see this in my button element <button type="button" onclick="javascript:'undefined'">1.5298600000000002,110.36003000000001</button> here is the full code <div class="col-12 form-group mt-5"> <div class="card" style="box-shadow: 0 0 8px rgb(0, 0, 0, 0.3)"> <h6 class="text-muted text-center p-3 mt-2">Map</h6> <div class="card-body"> <div id="googleMap" style="width: 100%; height: 400px"></div> </div> </div> </div> <div id="results"></div> <script> function myMap() { var mapProp = { position: new google.maps.LatLng(32.735316, -117.149046), zoom: 1, }; var map = new google.maps.Map( document.getElementById("googleMap"), mapProp ); } </script> <script src="https://maps.googleapis.com/maps/api/js?key=MYAPIKEY&callback=myMap"></script> <script> var coord_lists; load(coord_lists); function load() { const coordinates_lists = []; console.log(coordinates_lists); const map = new google.maps.Map(document.getElementById("googleMap"), { zoom: 5, center: coordinates_lists[0], mapTypeId: google.maps.MapTypeId.ROADMAP, }); map.setZoom(9); console.log(map); var locations = [ [1.5298600000000002, 110.36003000000001], [1.52872, 110.36453], [1.5278, 110.36775000000002], [1.5273500000000002, 110.37160000000002], ]; function ZoomAndCenter() { map.setCenter( new google.maps.LatLng(locations[i][0], locations[i][1]) ); map.setZoom(15); } var result = ""; for (var i = 0; i < locations.length; i++) { result = result + "<button type='button' onclick=\"javascript:'" + ZoomAndCenter(locations[i]) + "'\">" + locations[i] + "</button>" + "<br>"; } document.getElementById("results").innerHTML = result.toString(result); var marker, i; var markers = []; for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][0], locations[i][1]), map: map, }); } } </script>
  3. I'm using clip-path to create this section divider. I wanted to add a shadow effect on the 6 sides of this section. I tried box shadow but it couldn't show the shadow on the sides of the section divider. The image below is the shadow effect that i wanted to create on my section divider. <section style=" clip-path: polygon(0 0, 50% 100px, 100% 0, 100% 100%, 0 100%);box-shadow: inset 0 0 10px 0 black;margin-top: -10px;padding-bottom: 3rem;background-color: #ffffff;"> <div class="container"> <div class="row"> </div> </div> </section> Can someone show a helping hand here, cuz i have been figuring this out since forever. It will be a great help!
  4. I'm using sweet alert to send the user a warning message that show to them that the information insert is not valid in PHP echo. I want the "okay" button link to the desire page but it just could not work. my developer console shows the error of login.php:29 Uncaught TypeError: Cannot read properties of undefined (reading 'then') but I have no idea how can I make this work. I spent hours searching here and there but it just don't. Anyone who lend me a helping hand will be truly appreciated. Thanks. Below are my codes: if (isset($_POST['login'])) { $email = $_POST['email']; $user_password = $_POST['user_password']; $sql = "SELECT * FROM users WHERE user_phone = '$email' OR username = '$email' "; $query = $conn->query($sql); if ($query->num_rows < 1) { echo '<script> swal({ title: "Wrong information", text: "Sorry, your login information is not in our system. Please check your username/email correctly.", confirmButtonText: "Okay"}).then(function() { window.location = "../login/index.php"; }); </script>'; }
  5. I apply the rules of bootstrap but my buttons seems to go out of its alignment. my "Buy Now" and "View More" buttons should be place at the right side of the each sections. But i can seems to make it with bootstrap. I do not want to use Css to align it because i wanted it to be responsive. Can anyone enlighten me to help me out with my issues? below here are my codes <div class="container"> <div class="row" id="myDIV"> <?php $sql = "SELECT * FROM products"; $query = $conn->query($sql); if (!mysqli_num_rows($query)) { echo ' <div class="col-12"> <div class="badge badge-danger">No Products Found</div> </div> '; } else { while ($row = $query->fetch_assoc()) { ?> <section id="product-display" style="z-index: 1;background: linear-gradient(180deg, <?php echo $row['product_section_colour']; ?> 25.52%, rgba(42, 86, 147, 0) 100%);"> <div class="container-fluid"> <div class="row"> <div class="col-2" style="top:-15px; left:-20px;"> <img style="height: 160px;width: 105px;left: -2px;top: -15px;border-radius: 0px;" loading="lazy" loading="lazy" id="product_img" src="images/product-main/<?php echo $row['product_photo']; ?>" alt=""> </div> <div class="col-6 text-justify" style="position: absolute;height: 68px;left: 22%;right: 27.05%;"> <p style="color:<?php echo $row['product_dec_colour']; ?>;font-size:20px; padding-bottom:2px;font-weight: 600;"><?php echo $row['product_title']; ?></p> <ul> <li style="color:<?php echo $row['product_dec_colour']; ?>;font-size:7px;position: absolute;height: 68px;top: 35px;line-height: 8px;font-weight: 400;"><?php echo $row['product_desc']; ?></li> </ul> </div> <div class="col-4"> <a href="product.php?cid=<?php echo $row['id']; ?>" class="btn btn-block buynow text-center" style="background: <?php echo $row['product_dec_colour']; ?>; color: <?php echo $row['product_section_colour']; ?>;">Buy Now</a> <a href="product.php?cid=<?php echo $row['id']; ?>" class="btn btn-block viewmore text-center" style="background: <?php echo $row['product_dec_colour']; ?>; color: <?php echo $row['product_section_colour']; ?>;">View More</a> </div> </div> </div> </section> <?php } } ?> </div> this are my css .buynow { min-height: 32px; background: #ffffff; box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.25); border-radius: 5px; font-family: Inter; font-style: normal; font-weight: normal; font-size: 12px; line-height: 15px; text-align: center; width: 90px; position: absolute; top: 17px; } .viewmore { min-height: 32px; background: #ffffff; box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.25); border-radius: 5px; font-family: Inter; font-style: normal; font-weight: normal; font-size: 12px; line-height: 15px; text-align: center; width: 90px; position: absolute; top: 58px; } section { height: 107px; width: 100%; left: 0px; top: 0px; border-radius: 0px; display: inline-block; } * { padding: 0px; margin: 0px; } ul li { list-style-position: outside; margin-left: 1em; } This is what my page currently looks like with the codes above and this is my design
  6. SELECT SUM(purchase_price) as total_price FROM ordered_items WHERE payment_term = 1 AND order_display = 'SHOW'AND order_datetime >= '" . $from_date . "' AND order_datetime <= '" . $to_date . "' ";
  7. I want to submit my data to the notifications table, I am not sure why do i got this type error. Can anyone lend me a helping hand and help me with this problem? $product_name = $row['cart_name']; $cn_product_name = $row['cn_cart_name']; $m_product_name = $row['m_cart_name']; $variable00 = 'New'; $variable01 = '新订单'; $variable02 = 'Pesanan Baharu'; $variable03 = '<b>Order No: #'; $variable04 = '</b><br>'; $variable05 = 'for'; $variable06 = 'is Placed Successfully'; $variable07 = '<b>订单号: #'; $variable08 = '</b><br>已成功下单'; $variable09 = ' 的'; $variable10 = '<b>Nombor Pesanan: #'; $variable11 = '</b><br>Pesanan untuk'; $variable12 = 'anda sudah berjaya'; $variable13 = 0; $nQuery = "INSERT INTO notifications (notification_title, cn_notification_title, m_notification _title, notification_date, notification_text, cn_notification_text, m_notification_text, user_id, seller_id, order_id, product_id, user_notify, seller_notify, admin_notify) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; $stmt= $conn->prepare($nQuery); $stmt->bind_param("sssssssiiiiiii",$variable00.$order_type, $variable01, $variable02, $now, $variable03.$order_id.$variable04.$order_type.$variable05.$quantity.$quantity_unit.$product_name.$variable06, $variable07.$order_id.$variable07.$quantity.$quantity_unit.$variable09.$cn_product_name, $variable10.$order_id.$variable11.$quantity.$quantity_unit.$m_product_name.$variable12, $user_id, $seller_id, $order_id, $product_id, $variable06, $variable06, $variable06); $stmt->execute();
  8. @requinixCan i know how to find out the malevolent software?
  9. My website has recently been attacked by badware and my SSL certificate has been revoked by Sectigo. I already tried the method suggested in https://www.stopbadware.org/badware. I found out that malicious files have been added to my server, which cause my website cannot be loaded. On the other hand, there was once I notice that all my files in the sever have been deleted. i remove the malicious codes added to my server and also did a review from Google Seach Console. There are no security issues found in my websites that have been reviewed by the google search console. Furthermore, I also use the Virus Scanner provided in my server to scan if there are any virus files that I have mislooked while checking it. But no luck, my SSL certificate has been revoked by Sectigo again due to phishing detected on my website. What are the other steps that I could do to solve this hacking problem that is occurring on my website? It has been bugging me for a long time and i know SSL certificate is so important to a website. What can i do with it? Any help will be appreciated. Thanks!
  10. I'm trying to do a bulk insert here using Array. But i am unable to get the `user_id `to save it into each row of the product that is added into the table using bulk insert. Can i know what is the way for me to insert my `user_id` from the `<select>` element and save it into the table called `cart`? This is how my `cart table` looks like after i successfully POST the items selected into the `cart` table. The `user_id` selected will only be saved into the first selected item. <div class="col-12"> <div class="card"> <div class="card-body"> <h4 class="card-title"> Step 2: Insert Selected Product Values</h4> <div class="table-responsive" style="max-height: 60vh"> <div> <?php if(isset($message)) { echo $message; } ?></div> <!--<form method="post" action="">--> <table class="table"> <thead class="text-primary"> <th style=" position: sticky;top: 0; background: white";> Product </th> <th style=" position: sticky;top: 0; background: white";> Name </th> <th style=" position: sticky;top: 0; background: white";> Avaliable Stock </th> <th style=" position: sticky;top: 0; background: white";> Item Price(RM) </th> <th style=" position: sticky;top: 0; background: white";> Insert Product Quantity </th> </thead> <tbody id="products"> <form action="includes/add-item-to-cart-invoice.php" method="POST"> <?php $product_id = $_REQUEST['id']; $ids = explode(",",$product_id); $ids = array_splice($ids, 0); foreach($ids as $product_id){ $sql = "SELECT *, products.id as product_id FROM products LEFT JOIN sellers ON products.seller_id = sellers.id WHERE products.id = '".$product_id."' ORDER BY product_created DESC "; $query = $conn->query($sql); { while ($row = $query->fetch_assoc()) { $max = $row['product_stock']; ?> <tr> <td> <img src="https:/mywebsite/<?php echo !empty($row['product_photo']) ? $row['product_photo'] : ''; ?>" style="height: 50px; width: 50px;"> </td> <td> <?php echo $row['product_title']; ?> </td> <td> <?php echo $row['product_stock']; ?> <?php echo $row['product_unit']; ?> </td> <td> <div class="col-md-6"> <input type="number" name="cart_price[]" step=".01" class="form-control text-center" required> </div> </td> <td> <div class="col-md-6"> <input type="number" name="cart_qty[]" step=".01" class="form-control text-center" required> </div> </td> <td> <div class="col-md-12"> <input type="hidden" name="cart_name[]" value="<?php echo $row['product_title']; ?>"> <input type="hidden" name="cn_cart_name[]" value="<?php echo $row['cn_product_title']; ?>"> <input type="hidden" name="m_cart_name[]" value="<?php echo $row['m_product_title']; ?>"> <input type="hidden" name="cart_image[]" value="<?php echo $row['product_photo']; ?>"> <input type="hidden" name="cart_unit[]" value="<?php echo $row['product_unit']; ?>"> <input type="hidden" name="product_id[]" value="<?php echo $row['product_id']; ?>"> <input type="hidden" name="seller_id[]" value="<?php echo $row['seller_id']; ?>"> </div> </td> </div> <?php } } } ?> </tbody> </table> </div> </div> </div> </div> <div class="col-12"> <div class="card"> <div class="card-body"> <h4 class="card-title"> Step 3: Select User</h4> <div class="col-md-12"> <div class="form-group"> <label>SELECT SELLER *</label> <select class="form-control" name="user_id[]" required> <option value="">Select Users</option> <?php $ssql = "SELECT * FROM users "; $squery = $conn->query($ssql); while ($srow = $squery->fetch_assoc()) { ?> <option value="<?php echo $srow['id'];?>" ><?php echo $srow['user_fullname'];?></option> <?php } ?> </select> </div> </div> <div class="d-flex p-4 justify-content-around"> <div class="row"> <button type="button" name="btn_delete" id="btn_previous" value="True" class="btn btn-danger btn-icon-split m-2" onclick="window.location='add-invoice.php'"> <span class="icon text-white-50"> </span> <i class="fa fa-arrow-left" aria-hidden="true"></i> <span class="text">Back</span> </button> <button type="submit" name="add_invoice_details" id="btn_next" value="True" class="btn btn-info btn-icon-split m-2"> <span class="icon text-white-50"> </span> <i class="fa fa-arrow-right" aria-hidden="true"></i> <span class="text">Next</span> </button> </div> </div> </form> </div> </div> </div> </div> </div> This is my includes/add-item-to-cart-invoice.php <?php include('../session.php'); $data =$_POST; echo"<pre>"; var_dump($data); $count = count($_POST['product_id']); foreach($_POST['product_id'] as $i => $value){ $sql = "INSERT INTO `cart` (`cart_name`,`cn_cart_name`,`m_cart_name`, `cart_image`, `cart_qty`, `cart_unit`, `cart_price`, `product_id`, `user_id`,`seller_id`) VALUES ( '{$_POST['cart_name'][$i]}', '{$_POST['cn_cart_name'][$i]}', '{$_POST['m_cart_name'][$i]}', '{$_POST['cart_image'][$i]}', '{$_POST['cart_qty'][$i]}', '{$_POST['cart_unit'][$i]}', '{$_POST['cart_price'][$i]}', '{$_POST['product_id'][$i]}', '{$_POST['user_id'][$i]}', '{$_POST['seller_id'][$i]}' )"; $conn->query($sql); } ?> Can i know what can i do so that the selected `user_id` will be saved into each and every row of the item selected?
  11. What i want to do here is to inser all my products into the table called cart. I used POST method in form action to post the data to my tables. But i am unsure why my data does not insert sucessfully into my cart tables. I make sure i named every variables properly but i do not know where did it goes wrong. can anyone please show me a helping hand? I really need help for this. Any form of help will be appreciated. Thanks!; <div class="col-12"> <div class="card"> <div class="card-body"> <form action="includes/add-item-to-cart-invoice.php" method="post"> <h4 class="card-title"> Step 2: Insert Selected Product Values</h4> <div class="table-responsive" style="max-height: 60vh"> <div> <?php if(isset($message)) { echo $message; } ?></div> <!--<form method="post" action="">--> <table class="table"> <thead class="text-primary"> <th style=" position: sticky;top: 0; background: white";> Product </th> <th style=" position: sticky;top: 0; background: white";> Name </th> <th style=" position: sticky;top: 0; background: white";> Avaliable Stock </th> <th style=" position: sticky;top: 0; background: white";> Item Price(RM) </th> <th style=" position: sticky;top: 0; background: white";> Insert Product Quantity </th> </thead> <tbody id="products"> <?php $product_id = $_REQUEST['id']; $ids = explode(",",$product_id); $ids = array_splice($ids, 0); foreach($ids as $product_id){ $sql = "SELECT *, products.id as product_id FROM products LEFT JOIN sellers ON products.seller_id = sellers.id WHERE products.id = '".$product_id."' ORDER BY product_created DESC "; $query = $conn->query($sql); { while ($row = $query->fetch_assoc()) { $max = $row['product_stock']; ?> <tr> <td> <?php echo $row['product_title']; ?> </td> <td> <?php echo $row['product_stock']; ?> <?php echo $row['product_unit']; ?> </td> <td> <div class="col-md-6"> <input type="number" name="cart_price" step=".01" class="form-control text-center" required> </div> </td> <td> <div class="col-md-6"> <input type="number" name="cart_qty" step=".01" class="form-control text-center" required> </div> </td> </div> <?php } } } ?> </tbody> </table> </div> </div> <div class="card-body"> <h4 class="card-title"> Step 3: Insert User ID</h4> <h6 class="card-title"><span class="text-danger">**Please make sure the User ID you enter exist**</span> </h6> <div class="form-group"> <label>SELECT SELLER *</label> <select class="form-control" name="user_id" placeholder="search user..." required> <!-- <option value="">Select a customer...</option> --> <?php $ssql = "SELECT * FROM users"; $squery = $conn->query($ssql); while ($srow = $squery->fetch_assoc()) { ?> <option value="<?php echo $srow['id'];?>" ><?php echo $srow['user_fullname'];?></option> <?php } ?> </select> </div> <div class="col-md-4"> <!-- <input type="number" name="user_id" class="form-control text-center" required> --> <input type="hidden" name="cart_name" value="<?php echo $row['product_title']; ?>"> <input type="hidden" name="cn_cart_name" value="<?php echo $row['product_title']; ?>"> <input type="hidden" name="m_cart_name" value="<?php echo $row['product_title']; ?>"> <input type="hidden" name="cart_image" value="<?php echo $row['product_photo']; ?>"> <input type="hidden" name="cart_unit" value="<?php echo $row['product_unit']; ?>"> <input type="hidden" name="product_id" value="<?php echo $row['id']; ?>"> <input type="hidden" name="seller_id" value="<?php echo $row['seller_id']; ?>"> </div> </div> </div> <div class="d-flex p-4 justify-content-around"> <div class="row"> <button type="button" name="btn_delete" id="btn_previous" value="True" class="btn btn-danger btn-icon-split m-2" onclick="window.location='add-invoice.php'"> <span class="icon text-white-50"> </span> <i class="fa fa-arrow-left" aria-hidden="true"></i> <span class="text">Back</span> </button> <button type="submit" name="add_invoice_details" id="btn_next" value="True" class="btn btn-info btn-icon-split m-2"> <span class="icon text-white-50"> </span> <i class="fa fa-arrow-right" aria-hidden="true"></i> <span class="text">Next</span> </button> </div> </div> </form> <!--</form>--> </div> </div> </div> </div> </div> This is my add-item-to-cart-invoice.php <?php include('../session.php'); if(isset($_POST['add_invoice_details'])) { $cart_name = $_POST['cart_name']; $cn_cart_name = $_POST['cn_cart_name']; $m_cart_name = $_POST['m_cart_name']; $cart_image = $_POST['cart_image']; $cart_qty = $_POST['cart_qty']; $cart_unit = $_POST['cart_unit']; $cart_price = $_POST['cart_price']; $product_id = $_POST['product_id']; $seller_id = $_POST['seller_id']; $user_id = $_POST['user_id']; // $sql = "SELECT * FROM cart WHERE product_id = '$product_id' AND user_id = '$user_id' "; $query = $conn->query($sql); if (!mysqli_num_rows($query)) { $sql = "INSERT INTO `cart` (`cart_name`,`cn_cart_name`,`m_cart_name`, `cart_image`, `cart_qty`, `cart_unit`, `cart_price`, `product_id`, `user_id`, `seller_id`) VALUES ('$cart_name','$cn_cart_name','$m_cart_name', '$cart_image', '$cart_qty','$cart_unit', '$cart_price', '$product_id', '$user_id', '$seller_id')"; } else { $row = $query->fetch_assoc(); $cart_qty = $_POST['cart_qty'] + $row['cart_qty']; $sql = "UPDATE cart SET `cart_qty` = '$cart_qty' WHERE product_id = '$product_id' AND user_id = '$user_id' "; } if($conn->query($sql)) { //$_SESSION['success'] = 'Product added to Cart'; } else { //$_SESSION['error'] = $conn->error; } header('Location: cart.php'); } ?>
  12. I'm trying to fetch the result based on the users selection in the select element. But i do not know where is the mistake i made, it just can't seems to fetch the correct result. Here are my codes: <table class="table"> <thead class="text-primary"> <th style=" position: sticky;top: 0; background: white";> Product </th> <th style=" position: sticky;top: 0; background: white";> Name </th> <th style=" position: sticky;top: 0; background: white";> Avaliable Stock </th> <th style=" position: sticky;top: 0; background: white";> Item Price(RM) </th> <th style=" position: sticky;top: 0; background: white";> Insert Product Quantity </th> </thead> <tbody id="products"> <?php $product_id = $_REQUEST['id']; $ids = explode(",",$product_id); $ids = array_splice($ids, 0); foreach($ids as $product_id){ $sql = "SELECT *, products.id as product_id FROM products LEFT JOIN sellers ON products.seller_id = sellers.id WHERE products.id = '".$product_id."' ORDER BY product_created DESC "; $query = $conn->query($sql); { while ($row = $query->fetch_assoc()) { $max = $row['product_stock']; ?> <tr> <td> <?php echo $row['product_title']; ?> </td> <td> <?php echo $row['product_stock']; ?> <?php echo $row['product_unit']; ?> </td> <td> <div class="col-md-6"> <input type="number" name="cart_qty" step=".01" class="form-control text-center" required> </div> </td> <td> <select name="price_range" id="price_range" class="form-control"> <option value="price_range1" selected><?php echo $row['weight_range1']; ?> <?php echo $row['product_unit']; ?></option> <option value="price_range2"> <?php echo $row['weight_range2']; ?><?php echo $row['product_unit']; ?></option> <option value="price_range3"><?php echo $row['weight_range3']; ?><?php echo $row['product_unit']; ?></option> <option value="price_range4"><?php echo $row['weight_range4']; ?> <?php echo $row['product_unit']; ?></option> </select> </td> <td> <div class="col-12 my-auto">RM <span id="product_price"> <input type="hidden" name="cart_price" value="<?php echo $row['product_price1']; ?>"> <?php echo $row['product_price1']; ?> </span>/<?php echo $row['product_unit']; ?> </td> </tr> </div> </div> <?php } } } ?> </tbody> </table> I use AJAX method to POST the selection result, here are the codes <script> $(document).ready(function() { $('#price_range').on('change', function() { var product_id = <?php echo $product_id ?>; var price_range = this.value; $.ajax({ url: "includes/fetch-price.php", type: "POST", data: { product_id: product_id, price_range: price_range }, cache: false, success: function(result){ $("#product_price").html(result); // console.log(price_range); } }); }); }); </script> Here is my fetch-price.php <?php require_once "../session.php"; $product_id = $_POST["product_id"]; $price_range = $_POST["price_range"]; $sql = mysqli_query($conn,"SELECT * FROM products where id = '$product_id' "); $scrow = mysqli_fetch_array($sql); if($price_range == 'price_range1') { echo '<input type="hidden" name="cart_price" value="'.$scrow['product_price1'].'">', $scrow['product_price1']; } else if($price_range == 'price_range2') { echo '<input type="hidden" name="cart_price" value="'.$scrow['product_price2'].'">', $scrow['product_price2']; } else if($price_range == 'price_range3') { echo '<input type="hidden" name="cart_price" value="'.$scrow['product_price3'].'">', $scrow['product_price3']; } else if($price_range == 'price_range4') { echo '<input type="hidden" name="cart_price" value="'.$scrow['product_price4'].'">',$scrow['product_price4']; } ?> any form of help will be appreciated thanks!
  13. I'm getting the error of GET `https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css net::ERR_CONNECTION_TIMED_OUT` in my console. I have place the correct URL but it does not load. May i know how can i solve this issue? <head> <meta charset="utf-8" /> <link rel="apple-touch-icon" sizes="76x76" href="./assets/img/logo.png"> <link rel="icon" type="image/png" href="./assets/img/logo.png"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <title> MyWebSite </title> <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' /> <!-- Fonts and icons --> <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet" /> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css" rel="stylesheet"> <!-- CSS Files --> <link href="./assets/css/bootstrap.min.css" rel="stylesheet" /> <link href="./assets/css/paper-dashboard.css?v=2.0.1" rel="stylesheet" /> <!-- CSS Just for demo purpose, don't include it in your project --> <link href="./assets/demo/demo.css" rel="stylesheet" /> <style> .card-title { font-size: 24px; } </style> </head> It cause my icons in my website were unable to show <div class="text-center"> <a href="sales-analysis.php" class="btn btn-info" ><i class="nc-icon nc-paper"></i> &emsp; View Sales Analysis</a> <a href="top-categories.php" class="btn btn-info" ><i class="nc-icon nc-bullet-list-67"></i> &emsp; View Top Categories </a> <a href="top-customer.php" class="btn btn-info" ><i class="fa fa-users" aria-hidden="true"></i> &emsp; View Top Customers </a> <a href="top-stock.php" class="btn btn-info" > <i class="nc-icon nc-app"></i> &emsp; View Top Stock </a> <a href="top-sales.php" class="btn btn-info" > <i class="fa fa-money" aria-hidden="true"></i> &emsp; View Top Sales </a> <a href="top-area.php" class="btn btn-info" ><i class="fa fa-map-marker" aria-hidden="true"></i> &emsp; View Top Area</a> </div>
  14. I'm creating dynamic tabs with dynamic content by using Bootstrap in PHP Mysql. what I want to do here is, display the order_date on the nav-tab and the content of each nav-tab will be displayed by the date of the customer made their orders. The date in each nav-tab can be shown properly according to the condition set, but the content of each nav-tab does not show according to the condition set. It just displays all of the data. Can I know how can I display the content according to the condition set? Let's say I clicked on the '2021-09-09' tab, the order that is only made on this date will be shown as the content of this nav_tab. Any form of help will be appreciated. thanks in advance! <?php $tab_query = "SELECT id,cast(order_datetime as date) AS ordered_date , order_status FROM ordered_items GROUP BY ordered_date order by order_datetime DESC LIMIT 7"; $tab_result = mysqli_query($conn, $tab_query); $tab_menu = ''; $tab_content = ''; $i = 0; while($row = mysqli_fetch_array($tab_result)) { if($i == 0) { $tab_menu .= ' <li class="active"><a href="#'.$row["ordered_date"].'" data-toggle="tab">'.$row["ordered_date"].'</a></li> '; $tab_content .= ' <div id="'.$row["ordered_date"].'" class="tab-pane fade in active"> '; } else { $tab_menu .= ' <li><a href="#'.$row["ordered_date"].'" data-toggle="tab">'.$row["ordered_date"].'</a></li> '; $tab_content .= ' <div id="'.$row["ordered_date"].'" class="tab-pane fade"> '; } $product_query = "SELECT*, cast(order_datetime as date) AS products_ordered_date , order_status FROM ordered_items LEFT JOIN products ON ordered_items.product_id = products.id WHERE order_datetime = '".$row["ordered_date"]."'"; $product_result = mysqli_query($conn, $product_query); if(!mysqli_num_rows($product_result)) { $tab_content .= '<tr> <td colspan="5"> <div class="badge badge-danger">No Order Found</div> </td> </tr>'; } while($sub_row = mysqli_fetch_array($product_result)) { $tab_content .= ' <tr> <td> #'.$sub_row["order_id"].' </td> <td> '.$sub_row["product_title"].' </td> <td> '.$sub_row["quantity"].' </td> <td> '.$sub_row["products_ordered_date"].' </td> <td> '.$sub_row["delivery_date"].' </td> </tr> '; } $tab_content .= '<div style="clear:both"></div></div>'; $i++; } ?> <div class="col-12"> <div class="card"> <div class="card-header"> <h4 class="card-title"> All Products</h4> <span> <a href="download-list/download-products.php" class="btn btn-info float-right mb-3"><i class="fa fa-download" aria-hidden="true"></i> Download Products List</a> </span> <span> <a href="download-list/download-products.php" class="btn btn-info float-right mb-3"><i class="fa fa-download" aria-hidden="true"></i> Download Products List</a> </span> </div> <div class="card-body"> <ul class="nav nav-tabs"> <li class="nav-item"> <ul class="nav nav-tabs"> <?php echo $tab_menu; ?> </ul> </li> </ul> </div> <div class="card-body"> <div class="table-responsive" style="max-height: 70vh"> <table class="table"> <thead class="text-primary"> <th style=" position: sticky;top: 0; background: white" ;> Order no </th> <th style=" position: sticky;top: 0; background: white" ;> Product Name </th> <th style=" position: sticky;top: 0; background: white" ;> Quantity </th> <th style=" position: sticky;top: 0; background: white" ;> Order Date </th> <th style=" position: sticky;top: 0; background: white" ;> Recieve by </th> <tr> <?php echo $tab_content; ?> </tr> </tbody> </table> </div>
  15. I'm creating dynamic tabs with dynamic content by using Bootstrap in PHP Mysql. what I want to do here is, display the order_date on the nav-tab and the content of each nav-tab will be displayed by the date of the customer made their orders. The date in each nav-tab can be shown properly according to the condition set, but the content of each nav-tab does not show according to the condition set. It just displays all of the data. Can I know how can I display the content according to the condition set? Let's say I clicked on the '2021-09-09' tab, the order that is only made on this date will be shown as the content of this nav_tab. Any form of help will be appreciated. thanks in advance! <?php $tab_query = "SELECT id,cast(order_datetime as date) AS ordered_date , order_status FROM ordered_items GROUP BY ordered_date order by order_datetime DESC LIMIT 7"; $tab_result = mysqli_query($conn, $tab_query); $tab_menu = ''; $tab_content = ''; $i = 0; while($row = mysqli_fetch_array($tab_result)) { if($i == 0) { $tab_menu .= ' <li class="active"><a href="#'.$row["ordered_date"].'" data-toggle="tab">'.$row["ordered_date"].'</a></li> '; $tab_content .= ' <div id="'.$row["ordered_date"].'" class="tab-pane fade in active"> '; } else { $tab_menu .= ' <li><a href="#'.$row["ordered_date"].'" data-toggle="tab">'.$row["ordered_date"].'</a></li> '; $tab_content .= ' <div id="'.$row["ordered_date"].'" class="tab-pane fade"> '; } $product_query = "SELECT*, cast(order_datetime as date) AS products_ordered_date , order_status FROM ordered_items LEFT JOIN products ON ordered_items.product_id = products.id WHERE order_datetime = '".$row["ordered_date"]."'"; $product_result = mysqli_query($conn, $product_query); if(!mysqli_num_rows($product_result)) { $tab_content .= '<tr> <td colspan="5"> <div class="badge badge-danger">No Order Found</div> </td> </tr>'; } while($sub_row = mysqli_fetch_array($product_result)) { $tab_content .= ' <tr> <td> #'.$sub_row["order_id"].' </td> <td> '.$sub_row["product_title"].' </td> <td> '.$sub_row["quantity"].' </td> <td> '.$sub_row["products_ordered_date"].' </td> <td> '.$sub_row["delivery_date"].' </td> </tr> '; } $tab_content .= '<div style="clear:both"></div></div>'; $i++; } ?> <div class="col-12"> <div class="card"> <div class="card-header"> <h4 class="card-title"> All Products</h4> <span> <a href="download-list/download-products.php" class="btn btn-info float-right mb-3"><i class="fa fa-download" aria-hidden="true"></i> Download Products List</a> </span> <span> <a href="download-list/download-products.php" class="btn btn-info float-right mb-3"><i class="fa fa-download" aria-hidden="true"></i> Download Products List</a> </span> </div> <div class="card-body"> <ul class="nav nav-tabs"> <li class="nav-item"> <ul class="nav nav-tabs"> <?php echo $tab_menu; ?> </ul> </li> </ul> </div> <div class="card-body"> <div class="table-responsive" style="max-height: 70vh"> <table class="table"> <thead class="text-primary"> <th style=" position: sticky;top: 0; background: white" ;> Order no </th> <th style=" position: sticky;top: 0; background: white" ;> Product Name </th> <th style=" position: sticky;top: 0; background: white" ;> Quantity </th> <th style=" position: sticky;top: 0; background: white" ;> Order Date </th> <th style=" position: sticky;top: 0; background: white" ;> Recieve by </th> <tr> <?php echo $tab_content; ?> </tr> </tbody> </table> </div> </div>
  16. I'm creating a dynamic tabs with dynamic content by using Bootstrap in PHP Mysql. what i want to do here is, i display the order_date on the nav-tab and the content of each nav-tab will be display by the date of the customer made their orders. But i can't figure out why my nav-tab with dates are showing, but my content isn't showing, i've checked my database, there is no problem in there. I need help from you all, any form of help will be appreciated. thanks! <?php $date_sql = "SELECT id,cast(order_datetime as date) AS ordered_date , order_status FROM ordered_items GROUP BY ordered_date order by order_datetime DESC LIMIT 7"; $resultset = mysqli_query($conn, $date_sql) or die("database error:". mysqli_error($conn)); $order_status = 0 ; $nav_tab_html = ''; $ordered_items_html = ''; while( $nav_tab = mysqli_fetch_assoc($resultset) ) { $current_tab = ""; $current_content = ""; $nav_tab_html.= '<li class="'.$current_tab.'"><a class="nav-link" href="#'.$nav_tab['ordered_date'].'" data-toggle="tab">'. $nav_tab['ordered_date'].'</a></li>'; $ordered_items_html .= '<div id="'.$nav_tab["ordered_date"].'" class="tab-pane fade '.$current_content.'">'; $ordered_tab_sql = "SELECT*, cast(order_datetime as date) AS products_ordered_date , order_status FROM ordered_items LEFT JOIN products ON ordered_items.product_id = products.id WHERE order_datetime = '".$nav_tab["ordered_date"]."'"; $ordered_tab_results = mysqli_query($conn, $ordered_tab_sql) or die("database error:". mysqli_error($conn)); if(!mysqli_num_rows($ordered_tab_results)) { $ordered_items_html .= '<br>No order found!'; } while($ordered_item_tab = mysqli_fetch_assoc($ordered_tab_results) ) { $ordered_items_html .= '<div class="col-md-3 product">'; $ordered_items_html .= '<img src="https://mywebsite/images/'.$ordered_item_tab["product_photo"].'" class="img-responsive img-thumbnail product_image" />'; $ordered_items_html .= '</div>'; } $ordered_items_html .= '<div class="clear_both"></div></div>'; } ?> <div class="col-12"> <div class="card"> <div class="card-header"> <h4 class="card-title"> All Products</h4> <span> <a href="download-list/download-products.php" class="btn btn-info float-right mb-3"><i class="fa fa-download" aria-hidden="true"></i> Download Products List</a> </span> <span> <a href="download-list/download-products.php" class="btn btn-info float-right mb-3"><i class="fa fa-download" aria-hidden="true"></i> Download Products List</a> </span> </div> <div class="card-body"> <ul class="nav nav-tabs"> <li class="nav-item"> <ul class="nav nav-tabs"> <?php echo $nav_tab_html; ?> </ul> </li> </ul> </div> <div class="tab-content"> <?php echo $ordered_items_html; ?> </div> </div>
  17. But it will automatically create a new row in the database where the order_id will be 0. How do i avoid that?
  18. How do I prevent empty data from inserting into my database. I am implementing the feature of uploading the data into the database using CSV file. But i am facing a problem here, where those empty rows of data in my database will be also insert into my database. How can i prevent that from happen? these are my codes <?php include 'conn.php'; $preparing = 2; $row=1; if(isset($_POST["import"])){ $fileName = $_FILES["file"]["tmp_name"]; if($_FILES["file"]["size"]>0){ $file=fopen($fileName,"r"); while(($column = fgetcsv($file,1000,","))!== FALSE){ if($row == 1){ $row++; continue; } $num = count($column); $sqlInsert="INSERT INTO `ordered_items` (`order_id`,`user_id`,`seller_id`, `product_id`,`quantity`,`quantity_unit`,`product_buy_price`,`discount_price`,`other_charges`,`purchase_price`, `delivery_date`,`order_datetime`,`order_status`,`item_deliver_method`,`payment_term`) VALUES ('" .$column[0] . "','" .$column[1] . "','" .$column[2] . "','" .$column[3] . "', '" .$column[4] . "','" .$column[5] . "','" .$column[6] . "','" .$column[7] . "', '" .$column[8] . "','" .$column[9] . "' ,'" .$column[10] . "' ,'" .$column[11] . "' ,'" .$preparing . "','" .$column[12] . "','" .$column[13] . "')"; $result = mysqli_query($conn, $sqlInsert); $sql = "SELECT * FROM invoice_price WHERE order_id = ('".$column[0]."') "; $query = $conn->query($sql); if (!mysqli_num_rows($query)) { $invoicesql = "INSERT INTO `invoice_price`(`order_id`) VALUES ('".$column[0]."')"; $invoicequery = $conn->query($invoicesql); } else{ $sql = "UPDATE `invoice_price` SET `order_id`=('".$column[0]."') WHERE order_id = ('".$column[0]."') "; } if(!empty($result)){ echo '<script>alert("csv file sucessfully uploaded") window.location.href = "orders.php"</script>'; }else{ echo '<script>alert("problem importing csv") window.location.href = "upload-orders.php"</script>'; } } } } ?> This is what i mean by empty data inserted into the database. Thanks. I do not want any data insertion when the order_id = 0
  19. I'm sorry that my question is unclear. What i want is to show multiple PDFs in one pdf files, so when i clicked on the download button on the PDF view, I can download a multiple pages of PDFs at the same time.
  20. I want to add the function of when the user checked on the checkbox from the table of content, it will show the selected checkbox data and display it in the same PDF file with multiple pages when the "download selected invoice " button is clicked. For example, each checked rows is a PDF file here. Suppose if i checked 6 rows, 6 pages of selected invoices will be shown the the same PDF file. I tried to use AJAX method to achieve this function but i do not know why it does not work. What i am trying to do here is i get the selected order_id and pass it to the download-in-bulk.php file. And i want to execute it one by one through loop. But i do not know why my code does not work. It somehow just went back to the home page of system when i did not direct it back to the home page. Can you all help me with this? on how to show multiple pages of invoices in the same PDF file. I really need this to work for my project. Thanks in advance <div class="col-12"> <div class="card"> <div class="card-header"> <h4 class="card-title">Print Orders</h4> <?php $sql = "SELECT *, ordered_items.id as orderno FROM ordered_items LEFT JOIN products ON ordered_items.product_id = products.id LEFT JOIN users ON ordered_items.user_id = users.id LEFT JOIN sellers ON ordered_items.seller_id = sellers.id WHERE ordered_items.order_status = 5 GROUP BY ordered_items.order_id ORDER BY ordered_items.order_datetime DESC "; $query = $conn->query($sql); $tot_orders = mysqli_num_rows($query); ?> <b class="float-left mt-4">Total Orders ( <span class="text-success">Completed </span>): <?php echo $tot_orders; ?></b> <span> <div class="card-body"> <div class="table-responsive" style="max-height: 70vh"> <table class="table"> <thead class="text-primary"> <th style=" position: sticky;top: 0; background: white"; > <input type="checkbox" id="checkAl"> </th> <th style=" position: sticky;top: 0; background: white";> Order NO / Delivery NO </th> <th style=" position: sticky;top: 0; background: white";> Delivery / Self Pick-up Date </th> <th style=" position: sticky;top: 0; background: white";> Order by </th> <th style=" position: sticky;top: 0; background: white";> Revieve Item Method </th> <th style=" position: sticky;top: 0; background: white";> Total Price </th> <th style="text-align:center;position: sticky;top: 0; background: white;"> Action </th> </thead> <tbody id="orders"> <?php if (!$tot_orders) { echo ' <div class="col-12"> <div class="badge badge-danger">No Orders Found</div> </div> '; } else { while ($row = $query->fetch_assoc()) { if($row['item_deliver_method'] == 1) { $item_delivery_method = '<span >Delivery</span>'; } if($row['item_deliver_method'] == 2) { $item_delivery_method = '<span >Self-Pickup</span>'; } $grantotal = 0.00; $totsql = "SELECT*, SUM(purchase_price) as total_price FROM ordered_items LEFT JOIN invoice_price ON ordered_items.order_id = invoice_price.order_id LEFT JOIN discount ON invoice_price.discount_id = discount.id WHERE ordered_items.order_id = '".$row['order_id']."' "; $totquery = $conn->query($totsql); $totrow = $totquery->fetch_assoc(); $total_purchase = $totrow['total_price']; $discount_amount = $totrow['discount_amount']; $round_off_value = $totrow['round_off_value']; if($totrow['discount_type'] == 1){ $grandtotal = $total_purchase - $discount_amount + $round_off_value ; } else{ $grandtotal = $total_purchase - ($total_purchase * $discount_amount/100) + $round_off_value ; } ?> <tr> <td> <input type="checkbox" id="checkItem" name="order_id[]" class="download-bulk"value="<?php echo $row["order_id"]; ?>"> </td> <td> #<?php echo $row['order_id']; ?> </td> <td> <?php echo $row['delivery_date']; ?> </td> <td> <?php echo $row['user_fullname']; ?> </td> <td class="text-center"> <?php echo $item_delivery_method; ?> </td> <td> RM<?php echo number_format ($grandtotal,2); ?> </td> <td class="text-left"> <a href="invoice.php?oid=<?php echo $row['order_id']; ?>&uid=<?php echo $row['user_id']; ?>" style="text-decoration: none;color: #000; " title="Invoice"> <i class="fa fa-print" aria-hidden="true"></i> Print Invoice </a> </br> <a class="text-danger" href="delivery-receipt.php?oid=<?php echo $row['order_id']; ?>&uid=<?php echo $row['user_id']; ?>" style="text-decoration: none;color: #000;" title="Delivery Receipt"> <i class="fa fa-print" aria-hidden="true"></i> Print Delivery Order </a> </td> </tr> <?php } } ?> </tbody> </table> </div> </div> </div> </div> </div> </div> <div class="row"> <button type="button" name="btn_download_bulk" id="btn_download_bulk" value="True" class="btn btn-danger btn-icon-split m-2"> <span class="icon text-white-50"> <i class="fa fa-trash-o"></i> </span> <span class="text">Download Selected Invoice</span> </button> </div> </div> <script> $("#checkAl").click(function () { $('input:checkbox').not(this).prop('checked', this.checked); }); </script> <script type="text/javascript"> $(document).ready(function(){ $('#btn_download_bulk').click(function(){ // if(confirm("Are you sure you want to delete these products?")) // { var id=[]; $(':checkbox:checked').each(function(i){ id[i] = $(this).val(); }); if(id.length === 0){ alert("Please select at least one invoice"); }else if (confirm("Are you sure you want to download these invoices?")){ document.location.href='download-in-bulk.php'; $.ajax({ url:'download-in-bulk.php', method:'POST', data:{id:id}, success:function(){ for(var i=0; i<id.length; i++){ $('tr#'+id[i]+'').css('background-color','#ccc'); $('tr#'+id[i]+'').fadeOut('slow'); } } }); } else{ return false; } }); }); </script> This is my download-in-bulk.php codes <?php include '../session.php'; require_once('tcpdf/tcpdf.php'); if(isset($_POST["order_id"])) { foreach($_POST["order_id"] as $oid) { class MYPDF extends TCPDF { // Page footer public function Footer() { // Position at 25 mm from bottom $this->SetY(-5); // Set font $this->SetFont('helvetica', '', 9); $this->SetTextColor(0,0,0); $this->Cell(0, 0, 'This receipt was generated by computer no signed was needed.', 0, 0, 'C'); $this->Ln(); } } $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); //$pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetTitle('Invoice'); $pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING); $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont('helvetica'); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetMargins(PDF_MARGIN_LEFT, '10', PDF_MARGIN_RIGHT); $pdf->setPrintHeader(false); $pdf->setPrintFooter(TRUE); $pdf->SetAutoPageBreak(TRUE, 10); $pdf->SetFont('times', '', 7); $pdf->setCellHeightRatio(0.45); $pdf->AddPage(); date_default_timezone_set("Asia/Kuala_Lumpur"); $htmlcontent=""; $isql = "SELECT *, DATE(order_datetime) as orderdate FROM ordered_items LEFT JOIN products ON ordered_items.product_id = products.id LEFT JOIN users ON ordered_items.user_id = users.id LEFT JOIN billing_address ON billing_address.user_id = users.id LEFT JOIN brand ON products.product_brand = brand.id LEFT JOIN sellers ON ordered_items.seller_id = sellers.id LEFT JOIN invoice_price ON ordered_items.order_id = invoice_price.order_id WHERE ordered_items.order_id = '".$order_id."' AND ordered_items.user_id= '".$user_id."' GROUP BY ordered_items.order_id"; $iquery = $conn->query($isql); while ($irow = $iquery->fetch_assoc()) { if($irow['payment_term'] == 1) { $payment_type = 'Cash'; } if($irow['payment_term'] == 2) { $payment_type = 'Credit'; } $htmlcontent .=' <table cellpadding="2" width="102%" style="background-color: #000;marging: 100px;"> <tr> <td style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 17px;"> Invoice Number </td> <td align="right" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 17px;"> #'.$order_id.' </td> </tr> </table> <p></p> <hr width = "102%" style="color: #DBDBDB;"> <tr> <td width="80%" align="justify" style="font-weight: normal;font-size: 10px;line-height: 17px;color: #000000;"> <b>'.$irow['user_fullname'].'</b> <b>(0'.$irow['user_phone'].')</b> <br> '.$irow['bill_address'].', '.$irow['bill_city'].', '.$irow['bill_postcode'].', '.$irow['bill_state'].' </td> <td width="20%" align="right" style="font-weight: bold;font-size: 10px;line-height: 17px;"> <b>'.$irow['orderdate'].'</b> </td> </tr> </table> '; $htmlcontent .=' <table cellpadding="2" width="102%" style=" marging: 100px;"> <tr> <td style="color:#000;font-weight: bold;font-size: 10px;line-height: 10px;"> Payment Term : '.$payment_type.' </td> </tr> </table> '; $htmlcontent .=' <table cellpadding="1" style="background-color: #4c4646;"> <tr> <td width= "8%" style="color:#FFF;font-weight: bold;font-size: 8px;line-height: 10px;"> No. </td> <td width= "60%" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> Product Title </td> <td width= "9%" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> U.Price </td> <td width= "7%" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> QTY </td> <td width= "7%" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> UOM </td> <td width= "11%"style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> Amount </td> </tr> </table> '; } $i = 0; $sql = "SELECT * FROM ordered_items LEFT JOIN products ON ordered_items.product_id = products.id WHERE ordered_items.order_id = '".$order_id."' "; $query = $conn->query($sql); while ($row = $query->fetch_assoc()) { $htmlcontent .=' <table id="receiptcontent" cellpadding="1" style="max-height: 1000px; "> <tr> <hr width = "102%"> <td width= "4%" style="font-weight: normal;font-size: 8px;line-height: 8px;color: #000000;"> '. ++$i .' . </td> <td width= "64%" style=" font-weight: normal;font-size: 8px;line-height: 8px;color: #000000;"> '.$row['product_title'].' </td> <td width= "8%"style=" text-align: justify; font-weight: normal;font-size: 8px;line-height: 8px;color: #000000;"> RM '.$row['product_buy_price'].' </td> <td width= "8%" style=" text-align: center;font-weight: normal;font-size: 8px;line-height: 8px;color: #000000;"> '.$row['quantity'].' </td> <td width= "7%" style=" text-align: center;font-weight: normal;font-size: 8px;line-height: 8px;color: #000000;"> '.$row['quantity_unit'].' </td> <td width= "4%" style="font-weight: normal;font-size: 8px;line-height: 8px;color: #000000;"> RM </td> <td width= "6%"style="text-align: right; font-weight: normal;font-size: 8px;line-height: 8px;color: #000000;"> '.$row['purchase_price'].' </td> </tr> </table> '; } $totsql = "SELECT SUM(purchase_price) as total_price , order_id FROM ordered_items WHERE order_id = '".$order_id."' "; $totquery = $conn->query($totsql); while ($totrow = $totquery->fetch_assoc()) { $htmlcontent .=' <p></p> <table cellpadding="3" style="background-color: #4c4646;"> <tr> <td width="86.8%" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> Sub Price </td> <td width="6%" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> RM </td> <td width="10%"align="right" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> '.number_format($totrow['total_price'],2).' </td> </tr> </table> <br> '; } $sub_price = 0.00; $total_price = 0.00; $sql1="SELECT *, SUM(purchase_price) as ordertotalprice FROM ordered_items LEFT JOIN invoice_price ON ordered_items.order_id = invoice_price.order_id LEFT JOIN discount ON invoice_price.discount_id = discount.id WHERE ordered_items.order_id = '".$order_id."' "; $query1 = $conn->query($sql1); $row1 = $query1->fetch_assoc(); $discount_price = $row1['discount_amount']; $price = $row1['ordertotalprice']; if($row1['ordertotalprice'] < 500.00 && $row1['item_deliver_method'] == 1){ $deliveryfee = 10.00; $total_price = $sub_price + $deliveryfee; }else{ $deliveryfee = 0.00; $total_price = $sub_price + $deliveryfee; } if($row1['discount_type'==1]){ $deduct_price = $discount_price; }else{ $disprice = $price * ($discount_price/100); $deduct_price = $disprice; } $query1 = $conn->query($sql1); while ($row1 = $query1->fetch_assoc()) { $htmlcontent .=' <p></p> <table cellpadding="1"> <tr> <td width= "12.5%" style="color:#000;font-size: 8px;line-height: 2px;"> </td> <td width= "75%" style="color:#000;font-size: 8px;line-height: 2px;"> Delivery Fees </td> <td width= "9.5%" style="color:#000;font-size: 8px;line-height: 2px;"> RM </td> <td width= "5%" align="right" style="color:#000;font-size: 8px;line-height: 2px;"> '.number_format($deliveryfee,2).' </td> </tr> </table> <br> <p></p> <table cellpadding="1"> <tr> <td width= "12.5%" style="color:#000;font-size: 8px;line-height: 2px;"> </td> <td width= "75%" style="color:#000;font-size: 8px;line-height: 2px;"> Discount ('.$row1['discount_name'].') </td> <td width= "9.5%" style="color:#000;font-size: 8px;line-height: 2px;"> RM </td> <td width= "5%" align="right" style="color:#000;font-size: 8px;line-height: 2px;"> - '.number_format($deduct_price,2).' </td> </tr> </table> <br> <p></p> <table cellpadding="1"> <tr> <td width= "12.5%" style="color:#000;font-size: 8px;line-height: 2px;"> </td> <td width= "75%" style="color:#000;font-size: 8px;line-height: 2px;"> Round off </td> <td width= "9.5%" style="color:#000;font-size: 8px;line-height: 2px;"> RM </td> <td width= "5%" align="right" style="color:#000;font-size: 8px;line-height: 2px;"> '.$row1['round_off_value'].' </td> </tr> </table> <br> '; } $sub_price2 = 0.00; $total_price2 = 0.00; $sql2="SELECT *, SUM(purchase_price) as grandtotal FROM ordered_items LEFT JOIN invoice_price ON ordered_items.order_id = invoice_price.order_id LEFT JOIN discount ON invoice_price.discount_id = discount.id WHERE ordered_items.order_id = '".$order_id."' "; $query2 = $conn->query($sql2); $row2 = $query2->fetch_assoc(); $sub_price2 = $row2['grandtotal'] - $deduct_price + $row2['round_off_value'] ; if($row2['grandtotal'] < 500.00 && $row2['item_deliver_method'] == 1){ $deliveryfee = 10.00; $total_price2 = $sub_price2 + $deliveryfee; }else{ $deliveryfee = 0.00; $total_price2 = $sub_price2 + $deliveryfee; } $query2 = $conn->query($sql2); while ($row2 = $query2->fetch_assoc()) { $htmlcontent .=' <p></p> <table cellpadding="3" style="background-color: #000"> <tr> <td width="86.8%" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> Total Price </td> <td width="6%" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> RM </td> <td width="10%"align="right" style="color:#FFF;font-weight: bold;font-size: 10px;line-height: 10px;"> '.number_format($total_price2,2).' </td> </tr> </table> <br> '; } $pdf->IncludeJS($js); $pdf->writeHTML($htmlcontent); ob_end_clean(); $pdf->Output('invoice.pdf', 'D'); } } ?>
  21. Hi, I have a table of content in my page. For each row it has a check box. How do i achieve the function of when i click on submit button, those rows which are checked will be downloaded as a single pdf file. For example, for each checked row is a PDF file here. Suppose if i checked for 5 rows , 5 PDFs will be downloaded. Can i know how can i achieve this? Or is it not possible to do that for TCPDF library? If it is possible, i would appreciate if you guys could give me hints or some reading documentation to achieve this function. I have no idea how should i search for the solution for this function. Thanks in advance
  22. I need help here. I am creating a system where the user will be able to update the product stock by uploading the stock of the products according to the id that has been assigned to the product. this is how my products table in looks like in mysql database I tried the code below but all i could not update my data into my database. And there's not error shown on my code. I do not know what is wrong with my codes. Please help me. below the code that i use for uploading the CSV file to the data of my product_stock. <?php include 'conn.php'; if(isset($_POST["add_stock"])) { if($_FILES['product_file']['tmp_name']) { $filename = explode(".", $_FILES['product_file']['tmp_name']); if(end($filename) == "csv") { $handle = fopen($_FILES['product_file']['tmp_name'], "r"); while($data = fgetcsv($handle)) { $product_id = mysqli_real_escape_string($conn, $data[0]); $product_stock = mysqli_real_escape_string($conn, $data[1]); $product_status = 1 ; $query = "UPDATE products SET `product_stock` = '$product_stock', `product_status` = '$product_status' WHERE id = '$product_id'"; mysqli_query($conn, $query); } fclose($handle); header("location: upload-product.php?updation=1"); } else { echo '<script>alert("An error occur while uploading product. Please try again.") window.location.href = "upload-product.php"</script>'; } } else { echo '<script>alert("No file selected! ") window.location.href = "upload-product.php"</script>'; } } if(isset($_GET["updation"])) { echo '<script>alert("Product Stock Updated successfully!")</script>'; } ?> <div class="col-12"> <div class="card card-user"> <div class="card-header"> <h5 class="card-title">Update Product Stock</h5> <div class="card-body"> <div class="form-group"> <label for="file">Update Products stock File (.csv file)</label> <a href="assets/templates/product-template.xlsx" title="Download Sample File (Fill In Information and Export As CSV File)" class="mx-2"> <span class="iconify" data-icon="fa-solid:download" data-inline="false"> </a> </div> <form class = "form" action="" method="post" name="uploadCsv" enctype="multipart/form-data"> <div> <input type="file" name="product_file" accept=".csv"> <div class="row"> <div class="update ml-auto mr-auto"> <button type="submit" class="btn btn-primary btn-round" name="add_stock"> Import .cvs file</button> </div> </div> </div> </div> </form> </div> </div> This is the template that i require user to key in and saved it in CSV format before uploading it.
  23. I want to output the data and also the buttons in my php codes. But i do not know why the buttons does not output as coded. Can anyone let me know where did my codes go wrong? I've been searching it but i cant't find the problem. Thanks in advance. <?php if(isset($_POST['invoice_details'])) { $discountsql = "INSERT INTO `invoice_price` (`order_id`) VALUES ('.$order_id.') "; $conn->query($discountsql); } ?> <?php $sql2 = " SELECT order_id FROM ordered_items GROUP BY order_id WHERE order_id = '".$row[order_id]."' "; $query2 = $conn -> query($sql2); while ($row2 = $query2 -> fetch_assoc()) { ?> <div class="col-12 form-group"> <p> <?php echo $row2['order_id']; ?></p> <p class="text-success" pointer-events="none" style="font-weight: bold; font-size: 25px; text-align:center; ">Your order is confirmed !</p> <a href="order-list.php"> <input class="btn btn-block checkoutbtn" type="button" name="invoice_details" value="Go to Order Page"> </a> </div> <?php } ?>
  24. What i want to do is to insert the data where the same order_id will not be duplicated. Which means, i have order_id of order_id 1001 1001 1001 1002 1002 1034 1034 1034 1034 1066 in the table "ordered_items". Now i want the order_id to be saved in the "invoice_price" looks like this order_id 1001 1002 1034 1066 you get what i mean? the same order_id will be inserted as one in the invoice_price table. There won't be duplicated order_id in the invoice_price table.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.