Updating table rows from different table data not working

I have two tables in my database. One called wp_tickets and another one called wp_tickets_regenerated.

I have two tables in my database. One called wp_tickets and another one called wp_tickets_regenerated.

I'm trying to update some of the data in the wp_tickets_regenerated table from the wp_tickets table if the lottery_id matches so i end up with a new table with different ticket_number generated for each order placed for that product.

The code I have so far is throwing up an error:

 WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM wp_tickets
        WHERE lottery_id = wp_tickets.lottery_id' at line 6 for query UPDATE wp_tickets_regenerated

Can anyone help please?

wp_tickets table

+---------+-----------+-----------+---------------+----------+------------+
| user_id | full_name | answer_id | ticket_number | order_id | lottery_id |
+---------+-----------+-----------+---------------+----------+------------+
| 0       | test      | 1         | 3             | 791      | 790        |
+---------+-----------+-----------+---------------+----------+------------+
| 0       | test      | 1         | 5             | 791      | 790        |
+---------+-----------+-----------+---------------+----------+------------+
| 0       | test      | 1         | 10            | 791      | 790        |
+---------+-----------+-----------+---------------+----------+------------+

wp_tickets_regenerated

   +---------+-----------+-----------+---------------+----------+------------+
    | user_id | full_name | answer_id | ticket_number | order_id | lottery_id |
    +---------+-----------+-----------+---------------+----------+------------+
    |         |           |           | 1             |          | 790        |
    +---------+-----------+-----------+---------------+----------+------------+
    |         |           |           | 2             |          | 790        |
    +---------+-----------+-----------+---------------+----------+------------+
    |         |           |           | 3             |          | 790        |
    +---------+-----------+-----------+---------------+----------+------------+

What i have so far is:

 $wpdb->query(
       'UPDATE wp_tickets_regenerated
        SET user_id = wp_tickets.user_id,
            full_name = wp_tickets.full_name,
            answer_id = wp_tickets.answer_id,
            order_id = wp_tickets.order_id
        FROM wp_tickets
        WHERE lottery_id = wp_tickets.lottery_id'
  );


PHP / MySQL - Count how many table in database contain Specific name

I'm building an admin to control an interactive game, and I'm using PHP/MySql to store all the data for all the rounds. Each of the tables that I want to load into the game via PHP are titled "Puzzle*" with the * being an incremental index number. There are a few other tables in my database for global game data and bonus rounds.

I'm building an admin to control an interactive game, and I'm using PHP/MySql to store all the data for all the rounds. Each of the tables that I want to load into the game via PHP are titled "Puzzle*" with the * being an incremental index number. There are a few other tables in my database for global game data and bonus rounds.

What I want to be able to do is count the number of tables in my database that contain the name "Puzzle", and then use that total number as a randomizer to select a puzzle randomly. I plan to have roughly 50 puzzles, so an automated way of selecting a random puzzle, and then if I want to select another puzzle - to remove that previous puzzle from the list so that there is no chance of it being repeated until I start the whole game over again.

MySQL Database

Database Name: puzzleGame
Table 1: puzzle1
Table 2: puzzle2
Table 3: puzzle3
Table 4: puzzle4
Table 5: globals
Table 6: bonus


PhP MySQL Projects

PhP MySQL Projects

Simpliv LLC, a platform for learning and teaching online courses. We basically focus on online learning which helps to learn business concepts, software technology to develop personal and professional goals through video library by recognized industry experts and trainers.

Description
PHP Projects in Urdu is a comprehensive course. It has five PHP projects in Urdu. Each project is created from scratch. You will get source code of each project as well. The list of 5 projects is as under:

Project 1: Find and Replace Application
Project 2: Building an Email Marketing Application
Project 3: Creating a Contact Form
Project 4: Building a Search Engine For Database
Project 5: Building a PHP Quiz Application
As this is an intermediate level course so it has some requisites as well

This is a Urdu/Hindi video course

Who this Course is for:

Anyone who wants to learn Web development
Who wants to become a PHP Developer
Basic knowledge
You must have basic knowledge about PHP and Mysql
You must be able to write HTML and CSS as well
What will you learn
How to Find and Replace Application
How to Build an Email Marketing Application
How to Create a Contact Form
How to Build a Search Engine For Database
How to Build a PHP Quiz Application
To continue:

Inserting session array into mysql database

I am still learning bits of PHP and have been stuck on this issue regarding the POST data from radio buttons within a form being inserted into a mysql database from a session array. Currently, I have 2 questions within my survey and they consist of radio button options for a user to select from. The relevant answers can be selected and they are stored in a session array:

I am still learning bits of PHP and have been stuck on this issue regarding the POST data from radio buttons within a form being inserted into a mysql database from a session array. Currently, I have 2 questions within my survey and they consist of radio button options for a user to select from. The relevant answers can be selected and they are stored in a session array:

array(1) { ["choice"]=> array(2) { [0]=> string(11) "56-65 years" [1]=> string(17) "Prefer not to say" } }

However I was not too sure if the array should be as such. The two answers chosen from the radio options in the above example are "56-65 years" and "Prefer not to say".

Following on from the session array, I am trying to insert each of those answers in to a mysql database. I have a column created to insert each answer (i.e. there are two columns (question 1 and question 2) to store the two answers from the example above).

I am aware that my code is open to SQL injection and plan on fixing that after overcoming the inserting of data.

Question.php

     <form method="POST" action="process.php">
      <ul class="choices">
  &lt;?php while($row = $answers-&gt;fetch_assoc()):?&gt;
    &lt;li&gt;&lt;input type="radio" name="choice" value="&lt;?php echo $row['answerText']; ?&gt;"&gt;

    &lt;?php echo $row['answerText'] ?&gt;&lt;/li&gt;
    &lt;?php endWhile; ?&gt;

  &lt;/ul&gt; 
  &lt;input type="submit" name="submit" value="Next Question"&gt;
  &lt;input type="hidden" name="number" value="&lt;?php echo $number; ?&gt;"&gt;

</form>

Process.php

<?php

    if(isset($_POST['submit'])){

$number = $_POST['number'];
$next = $number+1;

$selected_choice = $_POST['choice'];
$_SESSION['choice'][] = $selected_choice;

foreach ($_SESSION['choice'] as $key) {

$user_responses = $key;

}

$insertdata = "INSERT INTO userAnswersTable('question1', 'question2') VALUES ($_SESSION['choice'])";
$resulting = $mysqli->query($insertdata) or die($mysqli->error.LINE);

}
?>

I would expect each of the user responses to be in an array from which each individual selected choice within the session array can be stored in each corresponding column within the mySql table. Any suggestions would be very helpful.