
- PHP & MySQL - Home
- PHP & MySQL - Overview
- PHP & MySQL - Environment Setup
- PHP & MySQL Examples
- PHP & MySQL - Connect Database
- PHP & MySQL - Create Database
- PHP & MySQL - Drop Database
- PHP & MySQL - Select Database
- PHP & MySQL - Create Tables
- PHP & MySQL - Drop Tables
- PHP & MySQL - Insert Records
- PHP & MySQL - Select Records
- PHP & MySQL - Update Records
- PHP & MySQL - Delete Records
- PHP & MySQL - Where Clause
- PHP & MySQL - Like Clause
- PHP & MySQL - Sorting Data
- PHP & MySQL - Using Joins
- PHP & MySQL - Handling NULL
- PHP & MySQL - Database Info
- PHP & MySQL Useful Resources
- PHP & MySQL - Quick Guide
- PHP & MySQL - Useful Resources
- PHP & MySQL - Discussion
Quiz on PHP MySQL Handling NULL Values
${quizData[index].explanation}`; explanationDiv.style.display = "block"; if (buttonSpan) { buttonSpan.textContent = "Hide Answer"; } // Find the correct option and highlight it with yellow background const correctRadio = document.querySelector(`input[name="q${index}"][value="${correctAnswerIndex}"]`); if (correctRadio) { // Find the parent list item and highlight it const correctOption = correctRadio.closest('li'); if (correctOption) { correctOption.style.backgroundColor = "#fff9b7"; } } } } function submitQuiz() { let score = 0, attempted = 0; quizData.forEach((q, index) => { // Since we've hidden the radio buttons, we need to check their state const selectedOption = document.querySelector(`input[name="q${index}"]:checked`); if (selectedOption) { attempted++; if (parseInt(selectedOption.value) === q.answer) score++; } }); if (attempted < Math.ceil(quizData.length / 2)) { alert(`Please attempt at least ${Math.ceil(quizData.length / 2)} questions before submitting.`); return; } document.getElementById("result").innerText = `You scored ${score} out of ${quizData.length}!`; document.querySelector(".review-btn").disabled = false; document.querySelector(".review-btn").classList.add("enabled"); document.querySelector(".result-container").style.display = "block"; // Destroy any existing chart to prevent duplicate rendering if (window.quizResultChart) { window.quizResultChart.destroy(); } // Create new chart and store reference window.quizResultChart = new Chart(document.getElementById("resultChart"), { type: 'pie', data: { labels: ["Correct", "Incorrect"], datasets: [{ data: [score, quizData.length - score], backgroundColor: ["#28a745", "#dc3545"] }] } }); } function reviewQuiz() { quizData.forEach((q, index) => { showQuizAnswer(index); }); document.querySelector(".review-btn").disabled = true; } loadQuiz();
Advertisements