prepare("UPDATE testimonials SET helpful_count = helpful_count + 1 WHERE id = :id"); $stmt->execute([':id' => $testimonialId]); // Get updated count $stmt = $pdo->prepare("SELECT helpful_count FROM testimonials WHERE id = :id"); $stmt->execute([':id' => $testimonialId]); $result = $stmt->fetch(PDO::FETCH_ASSOC); echo json_encode(['success' => true, 'count' => $result['helpful_count']]); exit; } } else { // Get all testimonials $stmt = $pdo->query("SELECT * FROM testimonials ORDER BY created_at DESC"); $testimonials = $stmt->fetchAll(PDO::FETCH_ASSOC); echo json_encode(['success' => true, 'data' => $testimonials]); } } catch(PDOException $e) { echo json_encode(['success' => false, 'message' => 'Error: ' . $e->getMessage()]); } ?>