Relation latest of many without ID

Sensors table

id  name        
1   Sensor no1
2   Sensor no2
3   Sensor no3

Temperatures table (log table)

temperature  sensor_id   timestamp
2.85         1           2021-10-19 18:37:34
5.05         2           2021-10-19 18:37:34
2.90         3           2021-10-20 18:37:34
5.65         1           2021-10-21 18:37:34
21.5         3           2021-10-22 18:37:34

In eloquent I have sensor model with relation

public function latestTemperature()
{
    return $this->hasOne(Temperature::class)->latestOfMany();
}

I get SQL error that temperatures.id does not exist. – I do not have ID in that table.
How can I tell it to where sensor id = x order by timestamp desc limit 1 or something?

Unknown column 'temperatures.id' 'field list'-s (SQL: select `temperatures`.* from `temperatures` inner join (select MAX(`temperatures`.`id`) as `id_aggregate`, `temperatures`.`sensor_id` from `temperatures` where `temperatures`.`sensor_id` in (1) group by `temperatures`.`sensor_id`) as `latestOfMany` on `latestOfMany`.`id_aggregate` = `temperatures`.`id` and `latestOfMany`.`sensor_id` = `temperatures`.`sensor_id`)

Use return data from one function in another and pass it to Smarty template

What I’m trying to do is to have one datatable probably as a template and passing different datas on different pages.

Example functions.php

function force() {
    global $DBconn;
    $q =  "SELECT * FROM table";
    $res = $DBconn->query($q);                              
    
    return $this->result;
}

function force_1() {
    global $DBconn;
    $q =  "SELECT * FROM table_1";
    $res = $DBconn->query($q);                              
    return $this->result;
}

function table() {

      echo '
         <table class="sortable">
            <thead>
            <tr>
                <th>
                    Title
                </th>
            </tr>
            </thead>
            <tbody>';
                foreach ($this->result as $key) {
               echo ' <tr>
                    <td>
                        $key->name
                    </td>
                </tr>';
                }
            echo '</tbody>
        </table>';
    }
  return true;
}

Then in the page.php

$table = table();
$smarty->assign("table", $table);

and page.tpl

<div> {$table} </div>

Currently nothing showed on page, not even an error or something. So:

  1. Is this the way that should be done? With using the returned result in either function and then pass it to the smarty template?

How to count number of rows that gets updated

I have made this code for the Controller:

public function updateUncompletedCarts(Request $request)
    {
        $uncompleted = Cart::where('crt_completed',0)->update([
            'crt_completed' => 1,
            'crt_changed' => 1,
        ]);
        $nums = count($uncompleted);
        
        Session::flash('carts-updated',$nums);
        
        return redirect()->back();
    }

Now I simply run an update query and then I wanted to show the number rows that gets affected and add it to a session so I can retrieve that in the Blade, like this:

@if(Session::has('carts-updated'))
    <div class="alert alert-success" role="alert">
        {{ Session::get('carts-updated') }}
        rows gets updated!
    </div>
@endif

But I get this error:

count(): Parameter must be an array or an object that implements Countable

Which is pointing to this line:

$nums = count($uncompleted);

So what’s going wrong here? How can I fix this issue?

Why the data is still updating even the textbox is empty? (Vue 2/Axios/PHP)

Good day everyone! When I enter the customer_address it updates the database even if I have not yet input the customer_first_name, customer_last_name and customer_contact_no. But if I don’t input the address he won’t update the row in the database. What do you think is the problem? How can I prevent the input from being empty.

//customer.js
identifyCustomerId : function(customer_id) {
            for(var index = 0; index < this.customers.length; index++) {
                if(customer_id == this.customers[index].customer_id) {
                    this.customer_first_name = this.customers[index].first_name;
                    this.customer_last_name = this.customers[index].last_name;
                    this.customer_contact_no = this.customers[index].contact_no;
                    this.customer_address = this.customers[index].address;
                }
            }
        },
openToggleUpdateForm : function(customer_id) {
            this.updateForm = true;
            this.toggleButton = false;
            this.customer_id = customer_id;
            this.identifyCustomerId(customer_id);

        },
 userValidation : function() {
            if(this.customer_first_name.trim() === "") {
                this.first_name_error = true;
                this.first_name_error_message = "This field is required!";
                console.log(this.first_name_error);
            }
            else {
                this.first_name_error = false;
                this.first_name_error_message = "";
            }
            if(this.customer_last_name.trim() == "") {
                this.last_name_error = true;
                this.last_name_error_message = "This field is required!";
            }
            else {
                this.last_name_error = false;
                this.last_name_error_message = "";
            }
            if(this.customer_contact_no.trim() == "") {
                this.contact_no_error = true;
                this.contact_no_error_message = "This field is required!";
            }
            else {
                this.contact_no_error = false;
                this.contact_no_error_message = "";
            }
            if(this.customer_address.trim() == "") {
                this.address_error = true;
                this.address_error_message = "This field is required!";
            }
            else {
                this.address_error = false;
                this.address_error_message = "";
            }
        },
updateCustomer : function() {
            this.userValidation();
            console.log(this.customer_first_name);
            axios.post(this.urlRoot + this.api + "update_customer.php", {
                customer_id : this.customer_id,
                first_name : this.customer_first_name,
                last_name : this.customer_last_name,
                contact_no : this.customer_contact_no,
                address : this.customer_address
            }).then(function (response) {
                if(response.data.status == "NOT OK") {
                    vm.first_name_error = response.data.first_name_error;
                    vm.last_name_error = response.data.last_name_error;
                    vm.contact_no_error = response.data.contact_no_error;
                    vm.address_error = response.data.address_error;
                } else{
                    console.log(response);
                    vm.retrieveCustomer();
                }
            }); 
        }
//update_customer.php (api)
$customer = new Customer();

    $data = json_decode(file_get_contents("php://input"),true);

    $response = [];

    $response['status'] = "OK";

    if(empty($data['customer_id'])) {
        $response['customer_id_error'] = true;
        $response['status'] = "NOT OK";
    }
    if(empty($data['first_name'])) {
        $response['first_name_error'] = true;
        $response['status'] = "NOT OK";
        echo $data['first_name'];

    }
    if(empty($data['last_name'])) {
        $response['last_name_error'] = true;
        $response['status'] = "NOT OK";
    }
    if(empty($data["contact_no"])) {
        $response["contact_no_error"] = true;
        $response["status"] = "NOT OK";
    }
    if(empty($data['address'])) {
        $response['address_error'] = true;
        $response['status'] = "NOT OK";
    }
    else{
        $customer = new Customer();

        $response['status'] = "OK";

        echo json_encode($response);
        $customer->customer_id = ucwords($data['customer_id']);
        $customer->first_name = ucwords($data['first_name']);
        $customer->last_name = ucwords($data['last_name']);
        $customer->contact_no = $data['contact_no'];
        $customer->address = ucwords($data['address']);
        $customer->updateCustomer();
    }
//customer_page.php ("update button on my table")
<button class="btn btn-secondary" @click="openToggleUpdateForm(customer.customer_id)">Update</button>

//customer_page.php ("update form")
<div class="add-content" v-if="updateForm">
                <h1>Add Customer</h1>
                <label>Firstname: </label>
                <input type="text" name="first_name" :class="{ invalid : first_name_error }" v-model="customer_first_name" required><br>
                <div class="text-danger">{{ first_name_error_message }}</div>
                <label>Lastname: </label>
                <input type="text" name="last_name" :class="{ invalid : last_name_error }" v-model="customer_last_name" required><br>
                <div class="text-danger">{{ last_name_error_message }}</div>
                <label>Contact no.: </label>
                <input type="text" name="contact_no" :class="{ invalid : contact_no_error }" v-model="customer_contact_no" required><br>
                <div class="text-danger">{{ contact_no_error_message }}</div>
                <label>Address: </label>
                <input type="text" name="address" :class="{ invalid : address_error }" v-model="customer_address" required><br>
                <div class="text-danger">{{ address_error_message }}</div>
                <div class="mt-4"> 
                    <button @click="updateCustomer()" class="btn btn-primary">Add</button>
                </div>
            </div>

How to save drop down Html form data into database using the following code?

This code is storing the data into php my admin database but i am not able to store the other fields excepts username and password.
so can anyone tell me the exact way how can i store the other fields using php?

only two fields are storing their data in database, username and password now i want to store the other fields too but i don’t know how to code it in php.
i am using wamp server .

and when i change some part of my code it will not store in the database. Please modify my curerent code so that i can perfectly run this small module.

Now that's all for this tutorial. Be sure to watch the video for good understanding.
    1. configure file contains the server and database name for references. 
       

<?php
/*
This file contains database configuration assuming you are running mysql using user "root" and password ""
*/

define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_NAME', 'new_sample');

// Try connecting to the Database
$conn = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

//Check the connection
if($conn == false){
    dir('Error: Cannot connect');
}

?>


2. Register.php file through which we want to register the user and saving the details into the database.

<?php
require_once "configure.php";

$userName=$designation=$role= $password = $confirm_password = "";
$userName_err = $password_err = $confirm_password_err = "";

if ($_SERVER['REQUEST_METHOD'] == "POST"){

    // Check if userName is empty
    if(empty(trim($_POST['userName']))){
        $userName_err = "userName cannot be blank";
    }
    else{
        $sql = "SELECT id FROM users WHERE userName = ?";
        $stmt = mysqli_prepare($conn, $sql);
        if($stmt)
        {
            mysqli_stmt_bind_param($stmt, "s", $param_userName);

            // Set the value of param userName
            $param_userName = trim($_POST['userName']);

            // Try to execute this statement
            if(mysqli_stmt_execute($stmt)){
                mysqli_stmt_store_result($stmt);
                if(mysqli_stmt_num_rows($stmt) == 1)
                {
                    $userName_err = "This userName is already taken";
                }
                else{
                    $userName = trim($_POST['userName']);
                }
            }
            else{
                echo "Something went wrong";
            }
        }
    }

    mysqli_stmt_close($stmt);


// Check for password
if(empty(trim($_POST['password']))){
    $password_err = "Password cannot be blank";
}
elseif(strlen(trim($_POST['password'])) < 5){
    $password_err = "Password cannot be less than 5 characters";
}
else{
    $password = trim($_POST['password']);
}

// Check for confirm password field
if(trim($_POST['password']) !=  trim($_POST['confirm_password'])){
    $password_err = "Passwords should match";
}


// If there were no errors, go ahead and insert into the database
if(empty($userName_err) && empty($password_err) && empty($confirm_password_err))
{
    $sql = "INSERT INTO users (userName, password) VALUES (?, ?)";
    $stmt = mysqli_prepare($conn, $sql);
    if ($stmt)
    {
        mysqli_stmt_bind_param($stmt, "ss", $param_userName, $param_password);

        // Set these parameters
        $param_userName = $userName;
        $param_password = password_hash($password, PASSWORD_DEFAULT);

        // Try to execute the query
        if (mysqli_stmt_execute($stmt))
        {
            header("location: login_sample2.php");
        }
        else{
            echo "Something went wrong... cannot redirect!";
        }
    }
    mysqli_stmt_close($stmt);
}
mysqli_close($conn);
}

?>





<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>USER MASTER</title>
<link href='http://fonts.googleapis.com/css?family=Bitter' rel='stylesheet' type='text/css'>
<style type="text/css">
body{
    background:#AEE4FF;
}
.form-style-10{
    max-width:750px;
    padding:30px;
    margin:40px auto;
    background: #FFF;
    border-radius: 10px;
    -webkit-border-radius:10px;
    -moz-border-radius: 10px;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.13);
    -moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.13);
    -webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.13);
}
.form-style-10 .inner-wrap{
    padding: 30px;
    background: #F8F8F8;
    border-radius: 6px;
    margin-bottom: 15px;
}
.form-style-10 h1{
    background: #2A88AD;
    padding: 20px 30px 15px 30px;
    margin: -30px -30px 30px -30px;
    border-radius: 10px 10px 0 0;
    -webkit-border-radius: 10px 10px 0 0;
    -moz-border-radius: 10px 10px 0 0;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.12);
    font: normal 30px 'Bitter', serif;
    -moz-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
    -webkit-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
    box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
    border: 1px solid #257C9E;
}
.form-style-10 h1 > span{
    display: block;
    margin-top: 2px;
    font: 13px Arial, Helvetica, sans-serif;
}
.form-style-10 label{
    display: block;
    font: 13px Arial, Helvetica, sans-serif;
    color: #888;
    margin-bottom: 15px;
}
.form-style-10 input[type="text"],
.form-style-10 input[type="date"],
.form-style-10 input[type="datetime"],
.form-style-10 input[type="email"],
.form-style-10 input[type="number"],
.form-style-10 input[type="search"],
.form-style-10 input[type="time"],
.form-style-10 input[type="url"],
.form-style-10 input[type="password"],
.form-style-10 textarea,
.form-style-10 select {
    display: block;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    -webkit-border-radius:6px;
    -moz-border-radius:6px;
    border: 2px solid #fff;
    box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.33);
    -moz-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.33);
    -webkit-box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.33);
}

.form-style-10 .section{
    font: normal 20px 'Bitter', serif;
    color: #2A88AD;
    margin-bottom: 5px;
}
.form-style-10 .section span {
    background: #2A88AD;
    padding: 5px 10px 5px 10px;
    position: absolute;
    border-radius: 50%;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border: 4px solid #fff;
    font-size: 14px;
    margin-left: -45px;
    color: #fff;
    margin-top: -3px;
}
.form-style-10 input[type="button"],
.form-style-10 input[type="submit"]{
    background: #2A88AD;
    padding: 8px 20px 8px 20px;
    border-radius: 5px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.12);
    font: normal 30px 'Bitter', serif;
    -moz-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
    -webkit-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
    box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
    border: 1px solid #257C9E;
    font-size: 15px;
}
.form-style-10 input[type="button"]:hover,
.form-style-10 input[type="submit"]:hover{
    background: #2A6881;
    -moz-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.28);
    -webkit-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.28);
    box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.28);
}
.form-style-10 .privacy-policy{
    float: right;
    width: 250px;
    font: 12px Arial, Helvetica, sans-serif;
    color: #4D4D4D;
    margin-top: 10px;
    text-align: right;
}
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  padding: 12px 16px;
  z-index: 1;
}

.dropdown:hover .dropdown-content {
  display: block;
}
</style>
</head>

<body>

<div class="form-style-10">
<h1>New User Details<span>Kindly fill all details of new user</span></h1>
<form action=""  method="POST">
    <div class="section"><span>1</span>User Name</div>
        <div class="inner-wrap">
        <label>User Name <input type="text" name="userName" placeholder="Enter User Name" required/></label>
    </div>

    <div class="section"><span>2</span>Designation</div>
    <div class="inner-wrap">
          <label required>Designation</label>
            <div>
      <select name="designation" id="Post">
            <option value="Select Designation">Select Designation</option>
        <option value="Director">Director</option>
        <option value="Deputy Director">Deputy Director</option>
        <option value="Assistant Director">Assistant Director</option>
        <option value="SI-I">SI-I</option>
            <option value="SI-II">SI-II</option>
            <option value="DPA A">DPA A</option></select>
            <br><br>
        </div>

        </div>

    <div class="section"><span>3</span>Role and Rights &amp; Passwords</div>
        <div class="inner-wrap">
        <label>Role and Rights</label>
                <div>
            <select name="role" id="Role">
                <option value="Select Designation">Select Role</option>
                <option value="Admin">Admin</option>
                <option value="User">User</option></select>
                <br><br>
                <label>Password <input type="password" name="password" placeholder="Enter Your Password" required /></label>
                <label>Confirm Password <input type="password" name="confirm_password" placeholder="Again Enter Your Password" required /></label>
    </div>
    <div class="button-section">
     <input type="submit" name="Submit" >
    </div>
</form>
</div>

</body>
</html>

Show column with information in new column

I have a table here in this example with 2 order numbers under sub-orders. Now I need the info in the user_c_56 column in the sub-orders as well.

The aunr column is assigned to the order number. Here is the original table and the way I would like it to be.

original table

As she should be

Here my query:

SELECT b.order_nr,
       b.user_c_56,
       b.aunr,
       s.a_atufe,
       z.mehrfach_kz,
       b.soll_dauer
FROM [hydra1].[hydadm].[v_auftrags_zusatz] z
     JOIN [hydra1].[hydadm].[auftrags_bestand] b ON z.auftrag_nr = b.aunr
     JOIN [hydra1].[hydadm].[auftrag_status] s ON b.auftrag_nr = s.auftrag_nr
WHERE s.eingeplant = ('M');

WordPress Hook execute before pre_get_post

I load products based on cookie for that i need to check cookie exist or not before pre_get_post hook execute. i tried parse_query hook this i will work but execute multiple times on load. I write code after cookie create reload page, due to multiple exe i’ve got error ERR_TOO_MANY_REDIRECTS.

Kindly please advise.

Laravel Trying to get property id of non-object

I am trying to update variables at About Us table, but i am getting this error. What is wrong?

AboutUsController:

   /**
     * Show the form for editing the specified resource.
     *
     * @param  AppModelsAboutUs $aboutUs
     * @return IlluminateHttpResponse
     */
    public function edit($aboutUs_id)
    {
        $aboutUs = AboutUs::find($aboutUs_id);
        return view('auth.aboutus.form',compact('aboutUs'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  AppModelsAboutUs $aboutUs
     * @return IlluminateHttpResponse
     */
    public function update(AboutUsRequest $request, AboutUs $aboutUs)
    {
        $params = $request->all();

        $aboutUs->update($request->all($params));

        return redirect()->route('aboutUs.index')->with('success','Post updated successfully');
    }

Here is my AboutUsRequest, where i am getting this error:

    public function rules()
    {
        $rules = [
            'title1' => 'required|min:5',
            'body1' => 'required|min:5',
        ];

        if ($this->route()->named('aboutUs.update')) {
            $rules['title1'] .= ',' . $this->route()->parameter('aboutUs')->id;
        }

        return $rules;
    }
}

Laravel 9 and ReactJS App gets a 401 unauthorized with api.php router

I am made an App with Laravel 9 back-end and ReactJS front-end and get a 401 unauthorized error even I am successfully logged-in in to my App.

Code is in api.php router and looks like below:

Route::post('/userdata', [AppHttpControllersProfileController::class, 'userData'])->middleware('auth')->name('userdata');

And here is a ProfileController:

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use IlluminateSupportFacadesAuth;
use IlluminateSupportStr;
use IlluminateFoundationAuthAccessAuthorizesRequests;
use IlluminateFoundationBusDispatchesJobs;
use IlluminateFoundationValidationValidatesRequests;

class ProfileController extends Controller
{
   private $apiToken;

   public function __construct()
   {
        $this->apiToken = uniqid(base64_encode(Str::random(40)));
        $this->middleware('auth');
    }

    /**
    * Get the user's profile.
    *
    * @param  Request  $request
    * @return Response
    */
    public function userData(Request $request)
    {
         $user = Auth::user();
         var_dump($user);
    
         return "";
     }
 }

Purpose of this controller is to get logged-in users details for ReactJS GUI.

And also here is a code in AuthController.php which make user logged-in:

    public function login(Request $request){
    //User check
    if(Auth::attempt(['email' => $request->email, 'password' => $request->password, 'is_active' => 1])){
        
        $user = Auth::user();
        
        if($user->email_verified_at !== NULL){
        
            if (DB::table('domains')
                ->select('domain', 'valid_before')
                ->where('domain', $user->domain)
                ->whereDate('valid_before_at', '<=', Carbon::now())
                ->count()){
                    return response()->json([
                       'success' => false,
                       'data' => 'Username and password do not match or domain subscription is not valid or expired!'
                    ], 200);
                
            } else { 
                 // Login and "remember" the given user...
                Auth::login($user, true); 
                //Setting login response 
                $success['token'] = $this->apiToken;
                $success['name'] =  $user->name;
                return response()->json([
                   'success' => true,
                   'data' => $success
                ], 200); 
            }

        } else {
            return response()->json([
                'success' => false,
                'data' => 'Please Verify Email!'
            ], 200);
        }
        
    } else {
        //$success['success'] = false;
        return response()->json([
            'success' => false,
            'data' => 'Username and password do not match or domain subscription is not valid or expired!'
        ], 200);
          
    }
}

Also if anyone wants to see whole source codes of am App there re publically here in my GIT repos:

https://bitbucket.i4ware.fi/projects/LOG/repos/login-form/browse?at=refs%2Fheads%2Fmatti_0006

https://bitbucket.i4ware.fi/projects/SAAS/repos/saas-app/browse?at=refs%2Fheads%2Fmatti_0008

Toggle switch display on selected

i would like to display creating product in admin section sub categories in tree only when selected else closed in woocommerce product categoreis.How can i achieve this.presently it appears like this. tried css but didn’t work

<li id="tire_sizes-52"><label class="radiall"><input value="52" type="checkbox" name="tax_input[tire_sizes][]" id="in-tire_sizes-52"> 145</label><ul class="children">

<li id="tire_sizes-62"><label class="radiall"><input value="62" type="checkbox" name="tax_input[tire_sizes][]" id="in-tire_sizes-62"> 65</label>    <ul class="children">

<li id="tire_sizes-87"><label class="radiall"><input value="87" type="checkbox" name="tax_input[tire_sizes][]" id="in-tire_sizes-87"> 15</label></li>
    </ul>
</li>
</ul>
</li>

i want it closed and open only if is selected

Including sidebar partial view with php MVC

I have to create a to-do application with PHP using MVC.
It’s obligated to use partials such as header.php, footer.php, …

However, I want to echo the sidebar as an inline element with my main content(.php).
But when I do this it get’s positioned as a column (obviously).

So I tried to render the sidebar.php into the content.php but it didn’t appear and in the browsers console, even funnier, the command that should import the sidebar.php got commented out..

I’m on the edge of just write sidebar content in a container from the content.php and drop the sidebar partial unless some of you can give me a clear way to do this. And with ‘this’, I mean a way to include the sidebar.php into my content so they are partials but inline.

If you want to see some code.. :

this is the index.php in the public folder

require '../resources/views/header.php';
//require '../resources/views/sidebar.php';
require '../App/bootstrap.php';
require '../resources/views/footer.php';

The main content is rendered with a controller through bootstrap.php

This is the controller that renders my main content (which is called application.php)

<?php 

namespace AppHttpControllers;

use AppProvidersView;

class MainController {
    public function mainApp() {
       return View::display('application.php');
    }
};

but I’ve written this inside the application.php file:

<?php 
include 'sidebar.php';
?>

Redirect multipe links using htaccess

I have shifted my website from one place to another. I have high traffic in the first place, so I need to redirect it on specific pages mapping to the second place. There are almost one thousand articles, so I need one thousand redirections. How to do that through htaccess?

I am using the described below HTACCESS CODE for this purpose but it is not working:

Redirect https://websiteOLD.com/article1 https://websiteNEW.com/article1

Redirect https://websiteOLD.com/article2 https://websiteNEW.com/article2

Redirect https://websiteOLD.com/article3 https://websiteNEW.com/article3

Redirect https://websiteOLD.com/article4 https://websiteNEW.com/article4

Redirect https://websiteOLD.com/article5 https://websiteNEW.com/article5

Redirect https://websiteOLD.com/article6 https://websiteNEW.com/article6

Whats wrong with the above described code lines? I have almost one thousand of such lines mapping each WordPress article from old domain to the new domain.

How can I select from stored procedures in CodeIgniter 4

I need help solving selecting from a procedure table from MySQL in Codelgniter and loading the data into Datatable. I am new to Codelgniter, for the past few days, I have been trying to solve this.

In my Controller I tried the following:

function get_vendors_sales_detail() {

     
        $customer = $this->input->get('customer') ? $this->input->get('custoproduct_codemer') : NULL;
        $start_date = $this->input->get('start_date') ? $this->input->get('start_date') : NULL;
        $end_date = $this->input->get('end_date') ? $this->input->get('end_date') : NULL;
        $user = $this->input->get('user') ? $this->input->get('user') : NULL;

        $this->load->library('datatables');
        $this->datatables
        ->select("sn, date, customer_name, product_name, product_code, total_items, unit_price  ")
        ->from('vendor03_product_sales');
        if ($this->session->userdata('store_id')) {
            $this->datatables->where('store_id', $this->session->userdata('store_id'));
        }
        $this->datatables->unset_column('id');
        if($customer) { $this->datatables->where('customer_name', $customer); }
        if($user) { $this->datatables->where('created_by', $user); }
        if($start_date) { $this->datatables->where('date >=', $start_date); }
        if($end_date) { $this->datatables->where('date <=', $end_date); }

        echo $this->datatables->generate();
        $this->page_construct('reports/vendors_sales_details', $this->data, $meta);
        

    }

But in my view, I am getting an error. I have tried making a search online but could not find what I need. I need help from Codelgniter experts.

Sign In With Google with custom buttons

I am using google library for social login with custom buttons but it is not opening the login popup.

Below is my code

<div class = "google-design-rest">
    <a href = "javascript:void();" ><i
            class = "fab fa-google"></i> {{ __('shop::app.customer.login-form.continue-with-google-button-text') }} </a>
    <!--end Google Check-->
    <div id = "g_id_onload" data-client_id = "{{ env('GOOGLE_CLIENT_ID') }}" data-context = "signup"
         data-ux_mode = "popup" data-callback = "handleCredentialResponse" data-auto_prompt = "false">
    </div>
    <div class = "g_id_signin" data-type = "standard" data-theme = "filled_blue" data-size = "large"
         data-text = "continue_with" data-shape = "rectangular" data-logo_alignment = "center"
         data-width = "500">
    </div>
</div>

If I use the default buttons then it’s working. There is no way provided by this version of the library to use it with custom buttons. There is no console error as well.
If anyone can provide me a way to make it work will be helpful.