Retrive data from database depends on a html table format

I have this table in a database

stid term subjects score
1 Term 1 English 70
1 Term 1 Math 80
1 Term 1 Science 98
1 Terminal English 85
1 Terminal Math 90
1 Terminal Science 100

I need to retrive data to display like this in a html table

SUBJECT TERM ONE TERMINAL AVERAGE
English 70 85 112.5
Math 70 85 85
Science 98 100 99

I’m new in SQL Queries I tried alot to run different sql command but i did not succeeded. I need your help.

my last query was this:

SELECT DISTINCT(subject),score FROM `examresults` WHERE stid='STD-1' GROUP BY subject,term

WordPress Meta Query Relation with Multiple Arguments

I am looking for a solution by which I can apply ‘OR’ relation depending upon the meta key,
In the below code you can see that 'relation' =>'AND' is applied which makes AND clause for every meta key like asset_category , asset_type .
If the post has true value for both asset_category and asset type then only post will be found in query.

What I want is different relation for different meta keys, for example:
Meta key active_inactive should be always true,
Meta key asset_category is optional so AND clause needs to apply on it

Can someone help me to make the code?
Any help appreciated.

$args = array(      
                'post_type'   => 'asset',
                's' => $keyword,
                'posts_per_page' => -1,
                'orderby'=>  'title' ,
                'order' => 'ASC',
                'post_status' =>'publish',
                'meta_query' => array(
                    'relation' =>'AND',
                    array(
                        'key' => 'active_inactive',
                        'value' => 'Active',
                        'compare' => '=',
                    ),
                )
            ); 
            if(isset($_GET['category'])){
                if(is_array($_GET['category'])){
                    foreach($_GET['category'] as $cat){
                        $args['meta_query'][]=array(
                          
                            'key' => 'asset_category',
                            'value' => $cat,
                            'compare' => 'LIKE',
                    ),
                );
                    }
                }else{
                    $args['meta_query'][]=array(
                        'key' => 'asset_category',
                        'value' => $_GET['category'],
                        'compare' => 'LIKE',
                    );
                    
                }
            }
            if(isset($_GET['assetType'])){
                if(is_array($_GET['assetType'])){
                    foreach($_GET['assetType'] as $cat){
                        $args['meta_query'][]=array(
                            'key' => 'asset_type',
                            'value' => $cat,
                            'compare' => 'LIKE',
                        );
                    }
                }else{
                    $args['meta_query'][]=array(
                        'key' => 'asset_type',
                        'value' => $_GET['asset_type'],
                        'compare' => 'LIKE',
                    );
                }
            }
            if(isset($_GET['levels'])){
                $args['meta_query'][]=array(
                    'key' => 'difficulty_level',
                    'value' => $_GET['levels'],
                    'compare' => 'IN',
                );
            }
            
            $wp_query_arr[] = new WP_Query($args);

“message”: “Quota exceeded for quota metric ‘Queries’ and limit ‘Queries per day’ of (truncated…)

I have a webcrawler application. And I try to return some search results.

And I do it with this method:

[
                    'htmlOptions' => ['style' => 'width: 150px'],
                    'name' => 'coc_number',
                    'value' =>  function (Result $result) {
                        $requestString = Google::GOOGLE_BASE_URL . 'key=' . Google::GOOGLE_API_KEY .
                            '&cx=' . Google::GOOGLE_CX . '&q=' . $result->page_url .
                            '"kvk"' . '&lr=lang_nl';


                        $clear = GuzzleHttpjson_decode((new Client)->request('GET', $requestString)->getBody()->getContents());
                      

                        if (property_exists($clear, 'items'))
                            foreach ($clear->items as $item)
                                if (property_exists($item, 'snippet'))
                                    if (strpos(($item->snippet), 'KvK') !== false) {
                                      
                                        preg_match('/[0-9]{8}/', $item->snippet, $match);

                                      

                                        if (isset($match[0])) {
                                            $result->coc_number = $match[0];
                                            $result->save();
                                        }
                                        sleep(4);
                                    }

                       
                        $this->redirect(Yii::app()->request->urlReferrer);

                        return $result->coc_number;
                    }
                ],

But when I execute this. I get this error:

GuzzleHttpExceptionClientException
Client error: `GET https://www.googleapis.com/customsearch/v1?key=AIzaSyC_xG9bUrJ2VcwHdRnB51rU3xbN2w2Zz7k&cx=017807248161955378400:1yvjei2ww6r&q=4%20Juli%20deken%20kopen%20bestellen&lr=lang_nl&num=10&start=1` resulted in a `429 Too Many Requests` response:
{
"error": {
"code": 429,
"message": "Quota exceeded for quota metric 'Queries' and limit 'Queries per day' of (truncated...)

So my question is: how to solve this?

Root composer.json requires package dev-develop, found package but it does not match the constraint

I forked a GitHub repo foo/bar that I want to install using composer.

I added

{
    "require": {
        foo/bar": "dev-develop"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/myuser/bar"
        }
    ]
}

My bar fork has a branch develop.
When I run composer install, I get:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires foo/bar dev-develop, found foo/bar[dev-main, v0.1.0] but it does not match the constraint.

Standalone PDO instance gets connected but I get an auth error when passed to redbean

This is my simple PDO instance example:

try {
            $dbh = new PDO('mysql:host=my-db-server-instance;port=3306;dbname=MY_DB_NAME','admin','mypass');
            foreach($dbh->query('SELECT * from user limit 10') as $row) {
                print_r($row);
            }
            $dbh = null;
            die();
    } catch (PDOException $e) {
            print "Error!: " . $e->getMessage() . "<br/>";
            die();
    }

This works as intended. The problem is when I try to use redbean with this PDO instance (Using setup method to pass params doesn’t work either):

$dbh = new PDO('mysql:host=my-db-server-instance;port=3306;dbname=MY_DB_NAME','admin','mypass');
R::setup($dbh);

This shows this auth error: code 500 — VERBOSE: Internal error: /srv/app/djf9839484/htdocs/service/vendor/gabordemooij/redbean/RedBeanPHP/Driver/RPDO.php line 206 : SQLSTATE[28000]: Invalid authorization specification: 1045 Access denied for user ‘admin’@’%’ (using password: YES)”

Have been checking sources and everything seems ok. Has anybody found a solution to this problem?

css A4 format adapted to multiple browsers

I must create a dynamic page through php, and the result must be an A4 printable page. Up here no problem, I have the page, and with Google Chrome I can view and print in A4 perfectly.

but

if I change the web browser, the A4 1 page is splitted into 2 pages (the last 2 or 3 lines on the 2nd page)

How may I adapt the print following the used browser? (maybe using css, or java, or php?)

thank everybody for your help

in my css I have this:

    .page {
    width: 210mm;
    min-height: 297mm;
    padding: 2mm;
    margin: 5mm auto;
    border: 1px #ffffff solid;
    border-radius: 5px;
    background: white;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}


@page {
    size: A4;
    margin: 0;
}
@media print {
    html, body {
        width: 210mm;
        height: 297mm;        
    }
    .page {
        margin: 0;
        border: initial;
        border-radius: initial;
        width: initial;
        min-height: initial;
        box-shadow: initial;
        background: initial;
        page-break-after: always;
    }
}

Laravel the script tried to call a method on an incomplete object

I just upgraded to Laravel 9 from v8 and suddenly I’m starting to get this error,

Error: The script tried to call a method on an incomplete object. Please ensure that the class definition "LaravelSerializableClosureSerializableClosure" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition
#35 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedClosure.php(68): IlluminateQueueCallQueuedClosure::handle
#34 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): IlluminateContainerBoundMethod::IlluminateContainer{closure}
#33 /vendor/laravel/framework/src/Illuminate/Container/Util.php(40): IlluminateContainerUtil::unwrapIfClosure
#32 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): IlluminateContainerBoundMethod::callBoundMethod
#31 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): IlluminateContainerBoundMethod::call
#30 /vendor/laravel/framework/src/Illuminate/Container/Container.php(610): IlluminateContainerContainer::call
#29 /vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): IlluminateBusDispatcher::IlluminateBus{closure}
#28 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): IlluminatePipelinePipeline::IlluminatePipeline{closure}
#27 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): IlluminatePipelinePipeline::then
#26 /vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): IlluminateBusDispatcher::dispatchNow
#25 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(118): IlluminateQueueCallQueuedHandler::IlluminateQueue{closure}
#24 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): IlluminatePipelinePipeline::IlluminatePipeline{closure}
#23 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): IlluminatePipelinePipeline::then
#22 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(120): IlluminateQueueCallQueuedHandler::dispatchThroughMiddleware
#21 /vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): IlluminateQueueCallQueuedHandler::call
#20 /vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): IlluminateQueueJobsJob::fire
#19 /vendor/laravel/framework/src/Illuminate/Queue/Worker.php(406): IlluminateQueueWorker::process
#18 /vendor/laravel/framework/src/Illuminate/Queue/Worker.php(356): IlluminateQueueWorker::runJob
#17 /vendor/laravel/framework/src/Illuminate/Queue/Worker.php(158): IlluminateQueueWorker::daemon
#16 /vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(116): IlluminateQueueConsoleWorkCommand::runWorker
#15 /vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(100): IlluminateQueueConsoleWorkCommand::handle
#14 /vendor/laravel/horizon/src/Console/WorkCommand.php(51): LaravelHorizonConsoleWorkCommand::handle
#13 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): IlluminateContainerBoundMethod::IlluminateContainer{closure}
#12 /vendor/laravel/framework/src/Illuminate/Container/Util.php(40): IlluminateContainerUtil::unwrapIfClosure
#11 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): IlluminateContainerBoundMethod::callBoundMethod
#10 /vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): IlluminateContainerBoundMethod::call
#9 /vendor/laravel/framework/src/Illuminate/Container/Container.php(610): IlluminateContainerContainer::call
#8 /vendor/laravel/framework/src/Illuminate/Console/Command.php(136): IlluminateConsoleCommand::execute
#7 /vendor/symfony/console/Command/Command.php(298): SymfonyComponentConsoleCommandCommand::run
#6 /vendor/laravel/framework/src/Illuminate/Console/Command.php(121): IlluminateConsoleCommand::run
#5 /vendor/symfony/console/Application.php(1015): SymfonyComponentConsoleApplication::doRunCommand
#4 /vendor/symfony/console/Application.php(299): SymfonyComponentConsoleApplication::doRun
#3 /vendor/symfony/console/Application.php(171): SymfonyComponentConsoleApplication::run
#2 /vendor/laravel/framework/src/Illuminate/Console/Application.php(93): IlluminateConsoleApplication::run
#1 /vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): IlluminateFoundationConsoleKernel::handle
#0 /artisan(37): null

The error is coming from the following file, line 33 which is dispatch(...):

<?php

namespace AppLogging;

use AppModelsHttpLog;
use IlluminateHttpRequest;

class CustomLogWriter implements SpatieHttpLoggerLogWriter
{
    public function shouldLogRequest(Request $request): bool
    {
        if ($request->hasFile('file')) {
            return false;
        }

        # default 
        // return in_array(strtolower($request->method()), ['post', 'put', 'patch', 'delete']);

        # firehose
        return true;
    }

    public function logRequest(Request $request)
    {
        if (config('feature.logAllHttpRequests')) {

            $log = [];
            $log['method'] = $request->getMethod();
            $log['url'] = $request->getPathInfo();
            $log['headers'] = json_encode($request->headers->all());
            $log['body'] = json_encode($request->except(config('http-logger.except')));

            dispatch(function () use ($log) {
                $newLog = new HttpLog;
                $newLog->url = $log['url'];
                $newLog->method = $log['method'];
                $newLog->headers = $log['headers'];
                $newLog->body = $log['body'];
                $newLog->created_at = now();
                $newLog->save();
            });
        }
    }
}

What do you think I am doing wrong?

Intégration de news api depuis codeigniter 4 project

Bonjour, je signale que je suis débutant avec le framework codeigniter 4. Avant d’utiliser celui-ci j’ai implémenter “news API”.
Et tout fonctionné mais là je ne vois mais par ou commencer avec le codeigniter 4 project si quelqu’un peut m’aider même avec une documentation sur ça.

How to show Laravel Nova(Version 4.0) action in Nova Resource Index?

Im new to nova framework .i need to use action method in Resource Index. According to documentation(https://nova.laravel.com/docs/4.0/actions/defining-actions.html)” ,If an action is enabled for display on the resource’s table row, you may also initiate the action from the resource’s action dropdown menu via the resource index page. These actions are referred to as “Inline Actions”:”
There is a public parameter for $showOnTableRow that you can set on the action.i used it in action nothing happens
And I can’t find any documentation on that. Has anyone figured out how to do it?

How to properly query products with URL in woocommerce?

how can I query products with title or description like an string in the URL;
so we passed the the search query with GET method to the URL, and we can get it by get_query_var('s'); so How to use this in this args array?

$args = [
    'post_type'      => 'product',
    'posts_per_page' => -1,
    's'         => get_query_var('s'),
    'meta_query' => [],
];
WP_Query($args);

is 's' => get_query_var('s'), the best soloution for searching here? My codes work but i’m seeking for a better searching functionality! Any idea?

How to submit session in API routes:

I want to submit a session at api. So at api.php, I did this:

Route::prefix('v1')->namespace('Apiv1')->group(function(){     
    Route::get('/test', function () {
        session()->put('user_phone_number', 'some value');
    });

    Route::get('/test2', function () {
        dd(session()->get('user_phone_number'));
    });
});

But results of dd(session()->get('user_phone_number')); is null somehow!

So the question is, how can I submit a session in Laravel API properly?

I want to change the color

I want help in modifying this code, as I want to add a color to these three names
TIME & Date & day

    <?php
        date_default_timezone_set("Africa/Cairo");
        // فرق التوقيت Tunis
        echo "TIME :  " . date("h:i:sa").
        "<br>"; // مسافه
        echo "Date :  " . date("Y/m/d").
        "<br>";
        echo "day :  " . date("l")
    ?>

PHP script cannot see the parent directory

I have a php script on a Ubuntu server which creates files. It works well with relative paths specified with `.’ but it does not see the parent directory.

header('X-Real-Path1: ' . realpath('..')); <-- empty string
header('X-Real-Path2: ' . realpath('.')); <-- returns the actual directory
header('X-Real-Path3: ' . realpath(__DIR__)); <-- returns the actual directory
header('X-Real-Path4: ' . realpath(__DIR__. '/../')); <-- empty string

The user which runs the script has full access to the directories. Why doesn’t the script see the directories?

code event[] calendar in laravel 8 not working

I created a calendar with laravel 8, I have successfully saved data in the database but the data in mysql does not appear in the calendar, even though I have used event[], I have checked that the data from mysql can come out but the data does not appear in the calendar, I can’t find error message, I sent my code for you to check, please help me, thx

K_JadwalController

public function index()
    {
        $data = K_Jadwal::all();
        return view('kkalender.index', compact('data'));
    }

index.blade.php

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Kalender | Inform</title>
    <meta name="csrf-token" content="{{ csrf_token() }}" />

    <!-- Google Font: Source Sans Pro -->
    <link rel="stylesheet"
        href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="{{ asset('AdminLte/plugins/fontawesome-free/css/all.min.css') }}">
    <!-- DataTables -->
    <link rel="stylesheet" href="{{ asset('AdminLte/plugins/datatables-bs4/css/dataTables.bootstrap4.min.css') }}">
    <link rel="stylesheet"
        href="{{ asset('AdminLte/plugins/datatables-responsive/css/responsive.bootstrap4.min.css') }}">
    <link rel="stylesheet" href="{{ asset('AdminLte/plugins/datatables-buttons/css/buttons.bootstrap4.min.css') }}">
    <!-- Theme style -->
    <link rel="stylesheet" href="{{ asset('AdminLte/dist/css/adminlte.min.css') }}">
    <link rel="stylesheet" href="{{ asset('plugins/fullcalendar/css/fullcalendar.min.css') }}">

    <meta name="csrf-token" content="{{ csrf_token() }}">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.css" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" />

</head>

<body>
<section class="content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-header">
                                    <h3 class="card-title">Daftar Data Kalender</h3>
                                </div>
                                <!-- /.card-header -->
                                <div class="card-body">
                                    <div id="calendar">


                                    </div>
                                </div>
                                <!-- /.card-body -->
                            </div>
                            <!-- /.card -->

                        </div>
                        <!-- /.col -->
                    </div>
                    <!-- /.row -->
                </div>
                <!-- /.container-fluid -->
            </section>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
        integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous">
    </script>
    <script>
        $(document).ready(function() {

            var SITEURL = "{{ url('/') }}";

            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            

            var bg_task = ["bg-teal", "bg-purple", "bg-warning", "bg-muted",
                "bg-primary", "bg-success", "bg-brown", "bg-pink", "bg-info"
            ];
            var calendar = $('#calendar').fullCalendar({
                header: {
                    left: 'prev, next today',
                    center: 'title',
                    right: 'month, agendaWeek, agendaDay',
                },
                editable: true,
                events: "{{ route('kkalender.index') }}",
                displayEventTime: true,
                eventRender: function(event, element, view) {
                    if (event.allDay === 'true') {
                        event.allDay = true;
                    } else {
                        event.allDay = false;
                    }
                },

                selectable: true,
                selectHelper: true,
                select: function(start, end, allDay) {
                    $('#dari').val(moment(start).format('YYYY-MM-DD HH:mm:ss'));
                    $('#sampai').val(moment(end).format('YYYY-MM-DD HH:mm:ss'));
                    $('#addModal').modal('toggle');

                },
                eventDrop: function(event, delta) {
                    var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD");
                    var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD");

                    $.ajax({
                        url: SITEURL + '/fullcalenderAjax',
                        data: {
                            title: event.title,
                            start: start,
                            end: end,
                            id: event.id,
                            type: 'update'
                        },
                        type: "POST",
                        success: function(response) {
                            displayMessage("Event Updated Successfully");
                        }
                    });
                },

                events: [
                    @foreach ($data as $value)
                        {
                            kategori: '{{ $value->kategori }}',
                            judul: '{{ $value->judul }}',
                            dari: '{{ $value->dari }}',
                            sampai: '{{ $value->sampai }}',
                            className: bg_task[Math.floor(Math.random() * bg_task.length)],
                        },
                    @endforeach
                ],

                eventClick: function(event) {
                    var deleteMsg = confirm("Do you really want to delete?");
                    if (deleteMsg) {
                        $.ajax({
                            type: "POST",
                            url: SITEURL + '/fullcalenderAjax',
                            data: {
                                id: event.id,
                                type: 'delete'
                            },
                            success: function(response) {
                                calendar.fullCalendar('removeEvents', event.id);
                                displayMessage("Event Deleted Successfully");
                            }
                        });
                    }
                }

            });

        });

        function displayMessage(message) {
            toastr.success(message, 'Event');
        }
    </script>
</body>

this is my route

Route::get('/kkalender', [K_JadwalController::class ,'index']);

your help means a lot to me, thx