How to create a multiple number guessing game with Javascript/PHP/any progamming language? [closed]

I want to create and understand how to create a multiple number guessing game like this: Number Guessing Game Example

I want to understand the algorithm of this program. Like how this program randomly generate a multiple number. And then, how do I know the random number that will be generated from this game. Like, how can I know what number will come out.

How to get Mailgun response With laravel Mail

How i can get the response from mailgun using Laravel mail.
Here is my code.

// In User Model.
$mail = Mail::send([], [], function ($message) use ($parsed_template) {
          $message
            ->to('[email protected]')
            ->subject('Test')
            ->setBody($parsed_template, 'text/html')
            ->addPart('Hello, welcome to Laravel!', 'text/plain');

     }); 

I can get the response in the the Listner using the Mailgun EVENT.

protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        'IlluminateMailEventsMessageSent' => [
            'AppListenersMailGunMailListner',
        ],
    ];

//   'AppListenersMailGunMailListner',

public function handle(MessageSent $event)
    {
        dd($event->message->getId());
    }

I can get the response in the listener, But How I can access it in the User model.

Thanks

typo3 – search bar and radio button filter doesn’t work together

I’m a new user a typo3 and I created an extension for searching shops and to show them in a map, my search system in work with a radio button filter and a search bar.

My issue is my radio buttons and my search bar are working only alone, for example when I write something and I didn’t click on a filter, or when I click on a filter and I didn’t write anything.

when I use them together they don’t work, I don’t have results, I don’t know why

there is some code :

controller :

    public function listAction()
    {
        $get = GeneralUtility::_GET();
        $results = $this->to32wContentRepository->sortByTypeTitle(
            $get['tx_import_search']['redirect']['formMap'] ?? null,
            $get['tx_import_search']['redirect']['search'] ?? null
        );

        $this->view->assign('formMap', $get['tx_import_search']['redirect']['formMap']);
        $this->view->assign('search', $get['tx_import_search']['redirect']['search']);
        $this->view->assign('results', $results);
    }

repository :

    public function sortByTypeTitle($type, $title)
    {
        $query = $this->createQuery();
        $query->getQuerySettings()->setRespectStoragePage(FALSE);
        $query->setOrderings([
            'title' => QueryInterface::ORDER_ASCENDING
        ]);

        $mission = new To32wContent();

        if ($type != NULL && $title != NULL) {
            $mission->setDisplayType($type);
            $oR = $query->logicalOr($query->like('title', '%'.$mission->getDisplayType(). '%'), $query->like('title', '%' . $title. '%'));
            $query->matching($query->logicalAnd($oR, $query->like('structure_cp', '%'.$title.'%')));
        } else if ($type != NULL && $title == NULL) {
            $mission->setDisplayType($type);
            $query->matching($query->like('title', '%'.$mission->getDisplayType(). '%'));
        } else if ($title != NULL && $type == NULL) {
            $query->matching($query->logicalOr($query->like('structure_cp', '%'.$title.'%'), $query->like('title', '%' . $title. '%')));
        }
        return $query->execute();
    }

someone have an idea to how can I solve my issue please?

Detele from DB with button [closed]

I want to delete info by click a button. So from select menu when i chose number from 1- 20 and push button NEXT is shows me “all the orders in that table from DB” When I push the button Finish in theory should delete all orders on the table i choose in DB. When i push the buutton it give me sql error.PLS help.

<?php
    require_once("connect.php");
    echo '<pre>'; print_r($_POST); echo '</pre>';
    
    if (isset($_POST['buton']))
    {   
        $tablenumber=$_POST['number'];
        $sql="SELECT orders.code,menu.name,orders.count,menu.price, orders.count*menu.price as Total 
        FROM orders,menu WHERE table_number=$tablenumber and orders.code=menu.code";    
        $quer=mysqli_query($conn,$sql)or die ('error sql');
        $num=mysqli_num_rows($quer);

        $sql2="SELECT  SUM(orders.count*menu.price) as TotalPrice 
        FROM orders,menu WHERE table_number=$tablenumber and orders.code=menu.code";    
        $quer2=mysqli_query($conn,$sql2)or die ('error sql2');      
    }
        if (isset($_POST['Finish']))    
        {   
            $tablenumber=$_POST['number'];
    
        $sql3=" DELETE FROM orders WHERE table_number=$tablenumber";
        $quer3=mysqli_query($conn,$sql3)or die ('error 1sql');
        }
    
?>
<html>
<form action="login.php" method="post">
<span style="display:flex; justify-content:flex-end; width:100%; padding:0;">
    <input type="submit" value="Exit"/>
</form>
</span>
        <style>
            body {background-color: #87CEEB;}
        </style>
    <head>
        <title>Factura</title>
        <!---<meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="dff.css"/>  !--->
    </head>
    <body>  
        <form id="frmFactura" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST">
                
           <div id="cabeceraFactura">
                <br>
                <SELECT NAME="number" size="1">
                    <option value="---">---</option>
                    <?php
                        for($i=1;$i<=20;$i++)
                        { echo "<option value=".$i.">".$i."</option>";}
                    ?>
                </SELECT>               
                <input type='submit' name='buton' value="NEXT"/>    
            </div>
            <br>
            <table id ="detalle" border="2" width="3" cellspacing="2" cellpadding="1">
                <thead>
                    <tr>
                     <th>Name</th>
                        <th>Count</th>
                        <th>Unit price</th>
                        <th>Total</th>
                    </tr>
                </thead>
                <tbody>
                <?php
                
                    if(isset($_POST['buton']))
                    {    while ($resul=mysqli_fetch_array($quer) )  
                        {   echo '
                    <tr>
                        <td><input class="descrip" type="text" name="naimenovanie" value="'.$resul["name"].'" disabled=""/></td>
                        <td><input class="cant" type="text" name="kolichestvo"  value="'.$resul["count"].'" disabled=""/></td>
                        <td><input class="vunit"type="text"  name="cena" value="'.$resul["price"].'" disabled=""/></td>
                        <td><input class="totPro" type="text"  name="obstho" value="'.$resul["Total"].'" disabled=""/></td>     
                    </tr>
                        ';
                        }
                    }       
                ?>
                </tbody>
            </table> 
            <br>
            <div class="Resultados">
                <table border="2" width="3" cellspacing="2" cellpadding="1">                  
                    <tr>
                        <td><label id="lbl">TotalPrice</label></td>
                        <?php
                            if(isset($_POST['buton'])) $resul2=mysqli_fetch_array($quer2);
                        ?>
                        <td><input class="totPro" type ="text" value="<?php if(isset($_POST['buton'])) 
                         echo $resul2['TotalPrice'];?>"  disabled=""/> </td>
                     
                    </tr>   
                </table>
                <br>
                <button onclick="window.print()" width="200">Print </button>    
                    <input type="submit"  name= "Finish" value = "Finish">
            </div>  
        </form>                                         
    </body>
</html>

How to delete the entire row in the database from html table instead of deleting entire table in the database

I have added delete button to the html table on each row and when clicked on delete button the entire row should be deleted but instead whole table in the database is being deleted.

here is my code for admin.php

    <div class="container mt-3 ml-3">
<table class="table">
    <thead>
    <tr>
        <th>S.No</th>
        <th>Name</th>
        <th>Email</th>
        <th>Rating</th>
        <th>Review</th>
        <th>Image</th>
        <th>Suggestion</th>
        <th>NPS</th>
        <th>Delete</th>
    </tr>
    </thead>
    <tbody class="table-warning">

<?php
include 'database_conn.php';      // makes db connection

$sql = "SELECT feedbackID, name, email, rating, review, image, suggestion, nps
        FROM feedback 
        ORDER BY feedbackID Desc";
$queryResult = $dbConn->query($sql);

// Check for and handle query failure
if($queryResult === false) {
    echo "<p>Query failed: ".$dbConn->error."</p>n";
    exit;
}
// Otherwise fetch all the rows returned by the query one by one
else {
    if ($queryResult->num_rows > 0) {
        while ($rowObj = $queryResult->fetch_object()) {
            echo "<tr>
                  <td>{$rowObj->feedbackID}</td>
                  <td>{$rowObj->name}</td>
                  <td>{$rowObj->email}</td>
                  <td>{$rowObj->rating}</td>
                  <td>{$rowObj->review}</td>
                  <td>{$rowObj->image}</td>
                  <td>{$rowObj->suggestion}</td>
                  <td>{$rowObj->nps}</td>
                  <td><a id='delete' href=delete.php?id={$rowObj->feedbackID}>Delete</a></td>
                  

              ";
        }

    }
}
?>

</tr>
    </tbody>
</table>
</div>

And here my code for delete.php. I think there is something wrong in the sql query I made.

    <?php
include 'database_conn.php';      // makes db connection


$sql = "DELETE FROM feedback WHERE feedbackID=feedbackID";

if ($dbConn->query($sql) === TRUE) {
    echo "Record deleted successfully. Please go to Customer Feedback Page by clicking"; echo "<a href='http://unn-w18031735.newnumyspace.co.uk/feedback/admin.php'> here</a>";
} else {
    echo "Error deleting record: " . $dbConn->error;
}

$dbConn->close();
?>

please need to fix this i cant add in my database [duplicate]

Notice: Undefined variable: title in C:xampphtdocssampleappadd_record.php on line 19

Notice: Undefined variable: task in C:xampphtdocssampleappadd_record.php on line 19
An error has been occured!PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘title’ cannot be null in C:xampphtdocssampleappadd_record.php:20 Stack trace: #0 C:xampphtdocssampleappadd_record.php(20): PDOStatement->execute(Array) #1 {main

This is my code

Check if name already exist in database but Id is not same in Laravel 6

Properties Table

id name
1 abc
2 xyz

I want to check if the name exists during edit but if it is the same Property then ignore it.

When I want to insert using this code

$ruls = [
        'property_type' => 'required',
        'project_name' => 'required|unique:properties,name',
    ];
$request->validate($ruls, []);     

and I want to using same validation when property edit like

select name from properties where name = name and id != 1

Please help me to solve this issue.

unzip file with vbs or powershell with password

I tried to find but without success.
I can unzip a ZIP file with batch FILE but it does not work when I have a password

These are the scripts I use:
One is bat and vbs:

cd /d %~dp0
Call :UnZipFile "c:ver" "c:tempverupdate.zip"
exit /b

:UnZipFile <ExtractTo> <newzipfile>
set vbs="%temp%_.vbs"
if exist %vbs% del /f /q %vbs%
>%vbs%  echo Set fso = CreateObject("Scripting.FileSystemObject")
>>%vbs% echo If NOT fso.FolderExists(%1) Then
>>%vbs% echo fso.CreateFolder(%1)
>>%vbs% echo End If
>>%vbs% echo set objShell = CreateObject("Shell.Application")
>>%vbs% echo set FilesInZip=objShell.NameSpace(%2).items
>>%vbs% echo objShell.NameSpace(%1).CopyHere(FilesInZip)
>>%vbs% echo Set fso = Nothing
>>%vbs% echo Set objShell = Nothing
cscript //nologo %vbs%
if exist %vbs% del /f /q %vbs%



The second in powershell:
PS1 file :

$jennyPath = gci -filter "test.zip" -recurse | Select-Object -ExpandProperty FullName

# step 2: unzip to current folder
$ShellExp = New-Object -ComObject Shell.Application
$zip = $ShellExp.NameSpace($jennyPath)
$pwd = (Get-Item -Path ".").FullName
$dest = $ShellExp.NameSpace($pwd)
$dest.Copyhere($zip.items(), 0x14) 


bat file :
powershell -executionpolicy bypass -Command "./unzip.ps1"

Getting the “bobot” value of the selected option on a dynamic form using PHP

I’m having a problem getting the selected weight value on a dynamic form I’m creating. Here’s the code for the get_recomendation.php form:

<form action="./get-recomendation-admin.php" method="POST" class="row justify-content-center">
   <?php $kriteria = $connection->query("SELECT * FROM kriteria"); while ($data = $kriteria->fetch_assoc()): ?>
       <div class="col-12 my-4 my-options">
           <label for="kriteria" class="form-label"><?=$data["nama"]?></label>
           <input type="hidden" class="form-control" id="id_kriteria" name="id_kriteria" readonly value="<?php echo $data['id_kriteria']; ?>">
           <input type="hidden" class="form-control" id="nama_kriteria" name="nama_kriteria" readonly value="<?php echo $data['nama']; ?>">
               <select class="form-select" id="bobot_kriteria" required="">
                    <option value="" disabled selected>Pilih Sub Kriteria</option>
                     <?php $t_kriteria = $connection->query("SELECT * FROM tingkat_kriteria"); while ($row = $t_kriteria->fetch_assoc()): ?>
                         <option value="<?=$row["bobot"]?>"><?=$row["nama"]?></option>
                     <?php endwhile; ?>
               </select>
       </div>
    <?php endwhile; ?>

    <div class="d-flex justify-content-center my-5">
         <button class="btn btn-dark mb-3 shadow-button fs-6 px-5 py-3" type="submit">Cari Rekomendasi</button>
    </div>
</form>

I tried to do a var_dump using the following code

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        var_dump($_POST['nama_kriteria']);
        var_dump($_POST['bobot_kriteria']); 
    }

result

string(5) "Harga"
Notice: Undefined index: bobot_kriteria in E:Program Filesxampphtdocsxxxxxxxxget-recomendation-admin.php on line 12
NULL

As for the output I want it’s like

Jenis Processor
10
Kapasitas RAM
20
XXXXX
XX
....

For the database I use like this

table tingkat_kriteria

| id    | nama            | bobot |
|:----: |:---------------:|:-----:|
| 1     | Sangat Penting  | 30    |
| 2     | Cukup Penting   | 25    |
| 3     | Cukup           | 20    |
| 4     | Kurang Penting  | 15    |
| 5     | Tidak Penting   | 10    |

and for the criteria table like this

table kriteria

| id    | nama            |
|:----: |:---------------:|
| 2     | Jenis Processor |
| 3     | Kapasitas RAM   |
| 4     | Jumlah Drive    |
| 8     | Harga           |

Selecting range of records from each category

I’ve a table called dept with dept_id as foreign key in participants table. Training is to be in 4 batches (A, B, C and D) the participants of the training are coming from 5 departments.

I need all the departments to be represented in each of the batches. How do I select 20 participants from each dept per batch? So that for each batches I will have 100 participants.
NOTE: I am not looking at any specific order for the selection, I t can be random or not.

I’ve this query so far:

SELECT dept.dept_name,
       participants.full_name,
       participants.email,
       participants.phone_number
FROM   participants
       JOIN dept
         ON participants.dept_id = dept.dept_id
WHERE  dept_name IN ( "lifestock", "fishery", "media", "foodtech", "extension" )
ORDER  BY participants_id
LIMIT  20;

Problem with post image url in woocomrece api

Hi I’m new in woocomrece API
and I want to send an image for my product, but every time I refresh the code with the same URL link new image media add to my WordPress media with a new link, and after like 10 times I have 10 duplicates of an image in media

<?php
$data = [
    'name' => $name,
    'type' => 'variable',
    'regular_price' => '50',
    'description' => $description,
    'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
    'categories' => [
        [
            'id' => $id_19
        ],
        [
            'id' => $id_23
        ]
    ],
    
    'images' => [
       
        
        [
            
            'src' => 'http://localhost/wordpress/wp-content/uploads/2022/03/arian-logo-1.png',

        ]
    ],
    'attributes' => [
        [
            'name' => 'color',
            'position' => 0,
            'visible' => true,
            'variation' => true,
            'options' => [
                'Black',
                'Green'
            ]
        ],
        [
            'name' => 'Size',
            'position' => 0,
            'visible' => true,
            'variation' => true,
            'options' => [
                'S',
                'M'
            ]
        ]
    ],
    'default_attributes' => [
        [
            'name' => 'color',
            'option' => 'Black'
        ],
        [
            'name' => 'Size',
            'option' => 'S'
        ]
    ]
];
($woocommerce->post('products', $data));
?>

Cannot extract columns from array using pluck

I’m trying to extract the id value from a list of associative array, this is the value of $request->post('files'):

array:2 [
  0 => array:2 [
    "id" => "21"
    "name" => "aviary-image-1429352137570.jpeg"
  ]
  1 => array:2 [
    "id" => "22"
    "name" => "1.jpg"
  ]
]

I tried:

$fileList = $request->post('files');
dd($fileList->pluck('id'));

But this returns:

Expected type ‘object’. Found ‘string|array|null’

So for the moment to fix this I have created a loop which iterates over the array and get only the id.

The expected result is: [21, 22]

Is there any way to do this without loop?