What are some recommended PHP books for beginners that cover topics like newsscripts and voting systems?

For beginners looking to learn PHP and specifically interested in topics like newsscripts and voting systems, some recommended books are "PHP for the Web: Visual QuickStart Guide" by Larry Ullman, "Learning PHP, MySQL & JavaScript: With jQuery, CSS & HTML5" by Robin Nixon, and "PHP and MySQL Web Development" by Luke Welling and Laura Thomson.

// Example PHP code snippet for a basic voting system
<?php
// Connect to database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

// Process user's vote
if(isset($_POST['vote'])){
  $vote = $_POST['vote'];
  
  // Insert vote into database
  $sql = "INSERT INTO votes (vote) VALUES ('$vote')";
  
  if ($conn->query($sql) === TRUE) {
    echo "Vote recorded successfully";
  } else {
    echo "Error: " . $sql . "<br>" . $conn->error;
  }
}

// Close database connection
$conn->close();
?>