/
home
/
u820193700
/
domains
/
throtllr.in
/
public_html
/
Upload File
HOME
<?php require 'C:\xampp\htdocs\ReOwn\includes\db.php'; // Find names in sell_requests that look like filenames $stmt = $pdo->query("SELECT id, name, phone FROM sell_requests WHERE name LIKE '%.jpg' OR name LIKE '%.jpeg' OR name LIKE '%.png' OR name LIKE '%.webp'"); $bad_requests = $stmt->fetchAll(); foreach ($bad_requests as $req) { $phone = $req['phone']; // Try to find the correct name in customers table $stmt2 = $pdo->prepare("SELECT name FROM customers WHERE RIGHT(phone, 10) = RIGHT(?, 10) AND name NOT LIKE '%.%' ORDER BY created_at DESC LIMIT 1"); $stmt2->execute([$phone]); $good_name_row = $stmt2->fetch(); if ($good_name_row && !empty($good_name_row['name'])) { $good_name = $good_name_row['name']; } else { // Try inspection_bookings $stmt3 = $pdo->prepare("SELECT name FROM inspection_bookings WHERE RIGHT(phone, 10) = RIGHT(?, 10) AND name NOT LIKE '%.%' ORDER BY created_at DESC LIMIT 1"); $stmt3->execute([$phone]); $good_name_row2 = $stmt3->fetch(); if ($good_name_row2 && !empty($good_name_row2['name'])) { $good_name = $good_name_row2['name']; } else { // Default if we can't find it $good_name = 'Customer'; } } // Update the sell_requests table $updateStmt = $pdo->prepare("UPDATE sell_requests SET name = ? WHERE id = ?"); $updateStmt->execute([$good_name, $req['id']]); echo "Updated ID " . $req['id'] . " from '" . $req['name'] . "' to '" . $good_name . "'\n"; } echo "Done."; ?>