Search results

  1. MilesWeb

    Do not echo empty field from Mysql

    Please check MYSQL table printing code : <?php if (trim($items['option_second']) != "") { echo "<strong>Option:</strong> {$items['option_second']}"; } ?> AND change option print code : <?= trim($items['option_second']) != "" ? "<strong>Option:</strong> {$items['option_second']}" : ""; ?>
  2. MilesWeb

    Calculating compound interest

    Check the updated PHP code, please: <?php if (isset($_POST['calculate'])) { $principal = ($_POST['principal']); $rate = ($_POST['rate'] / 100); // Convert percentage to decimal $time = ($_POST['time']); $compounds = ($_POST['compounds']); $amount = $principal * pow(1 + ($rate / $compounds)...
  3. MilesWeb

    embedding 2 short codes in one page breaks layout

    Please check below code : function boxed_product_shortcode($atts) { $atts = shortcode_atts( array( 'product_id' => 0, ), $atts, 'boxed_product' ); // PHP code ob_start(); ?> <div class="boxed-product boxed-product-<?php echo...
  4. MilesWeb

    Need help with PHP 8.1 and usort() function

    Simplify the comparison logic by using the spaceship operator ('<=>') protected function sortItemsByPrice($items, $order) { usort($items, function ($a, $b) use ($order) { return $a->getPrice() <=> $b->getPrice(); }); return $items; }
  5. MilesWeb

    mail(to,subject,message,headers); Not Working. H E L P !

    Hello, I am experiencing the same problem. please SMTP to send mail. require_once 'PHPMailer/PHPMailer.php'; require_once 'PHPMailer/SMTP.php'; require_once 'PHPMailer/Exception.php'; $mail = new \PHPMailer\PHPMailer\PHPMailer(true); try { //Server settings $mail->SMTPDebug = 0...
  6. MilesWeb

    Nested loops and SQL data

    Please check below code, $CTOQuery = "SELECT * FROM Training WHERE (Date BETWEEN '" . $_REQUEST['StartDate'] . "' AND '" . $_REQUEST['EndDate'] . "') ORDER BY CTO"; $CTOResult = sqlsrv_query($conn, $CTOQuery, array(), array("Scrollable" => SQLSRV_CURSOR_KEYSET)); //An array to store totals...
  7. MilesWeb

    Semiauto Select/Option code

    Please review the code below: <?php function do_enum ($db, $table, $ecol, $seled, $ab) { // remove unwanted data from inputs $table = mysqli_real_escape_string($db, $table); $ecol = mysqli_real_escape_string($db, $ecol); $seled = mysqli_real_escape_string($db, $seled); $ab...
  8. MilesWeb

    Nested loops and SQL data

    You can fetch data using while loop also, please referee below code, $CTOQuery = "SELECT * FROM Training WHERE (Date BETWEEN '" . $_REQUEST['StartDate'] . "' AND '" . $_REQUEST['EndDate'] . "') ORDER BY CTO"; $CTOResult = sqlsrv_query($conn, $CTOQuery, array(), array("Scrollable" =>...
  9. MilesWeb

    PHP Statement and PHP Script

    No, PHP statements and scripts are not the same but are related terms. A statement is a single line of code, while a PHP script is an overall code containing multiple statements that work together. Statement: A statement is an action or condition. Eg. $x = 5, echo "Hello"; Script: The script...
  10. MilesWeb

    API CURL Problem

    Okay, No problem.
  11. MilesWeb

    API CURL Problem

    Absolute 1 is not included in JSON. Do you have any additional print or echo information?
  12. MilesWeb

    API CURL Problem

    Hi, If you wish to print JSON, use echo to print JSON, e.g. echo $response, rather than var_dump. Moreover, use if you require an array from JSON. $responseData = json_decode($response, true); echo "<pre>"; print_r($responseData); i hope it will work for you.
  13. MilesWeb

    JOIN and GROUP BY

    Yes, you can accomplish this by combining JOIN and GROUP BY in SQL. SELECT m.`Business ID`FROM MAIN_DATA mLEFT JOIN ( SELECT `Business ID`, COUNT(*) AS reserved_count FROM ANIMAL_DATABASE WHERE Type = 'RESERVED' GROUP BY `Business ID`) a ON m.`Business ID` = a.`Business ID`WHERE...
  14. MilesWeb

    what is wrong with the code?

    You can update switch case code : switch ($month) { case 12: if ($h >= 6) { $sql = "INSERT INTO test2 (resultat, current) VALUES (100, 50)"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else {...
  15. MilesWeb

    The button does not send data to the database

    1. Missing the ID value in form : <input type="hidden" name="ID" value="<?php echo $data['ID'] ?>"> Kindly provide the ID filed some value so that the database may be updated. 2.The action may be empty if you are submitting data on the same page.
  16. MilesWeb

    loading but not showing

    try to locate php.ini correctly, Use php --ini for loaded configuration files. Make sure the path declared for php.ini is correct. check if PDO is enabled in phpinfo() output, you need to enable it first. you need to review your DNS format, mysql:host=localhost;dbname=mydb mysqlnd default...
  17. MilesWeb

    Heres a quickie is it \r\n or \n\r

    Hello, It is \r\n. I'm hoping it works out for you.
  18. MilesWeb

    javascript variable to php variable

    JavaScript runs on the client side and PHP runs on the server side, you cannot transfer JavaScript variables directly to PHP variables. Here's how to accomplish it: JavaScript <script> function myFunction() { var person = prompt("Enter your name", "John Smith"); if (person != null) {...
  19. MilesWeb

    search and replace in a folder full of text files

    Here's a simple illustration of how to accomplish this: <?php // text files path $folder = 'path/to/your/folder/'; // Enter search and replace strings $search = 'old_text'; $replace = 'new_text'; // Open the folder if ($handle = opendir($folder)) { // Loop through each file in the...
  20. MilesWeb

    Bash script to clone hard disk automatically.

    Hey, Can you please mention, which is the exact backup software you're using (either rsync, tar, BorgBackup, etc.) You need to understand directory structure of your existing backups on disk1:sda. Check out the preferred destination for backups on disk2:sdb. Also, you can use scripts disk1:sda...
Back
Top