connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Define random color array (no longer used if we’re removing text logo)
$colors = ['#FF5733', '#33B5FF', '#FFD700', '#8E44AD', '#27AE60', '#FF69B4', '#FF4500'];
// Query data
$sql = "SELECT id, url, title, logo, keywords, description, categorys, country FROM url_entries ORDER BY id DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// Output data
while ($row = $result->fetch_assoc()) {
// Limit field lengths
$title = mb_strlen($row['title']) > 20 ? mb_substr($row['title'], 0, 20) . '...' : $row['title'];
$keywords = mb_strlen($row['keywords']) > 50 ? mb_substr($row['keywords'], 0, 50) . '...' : $row['keywords'];
$description = mb_strlen($row['description']) > 100 ? mb_substr($row['description'], 0, 100) . '...' : $row['description'];
// Get logo or default placeholder
$logo = $row['logo'];
// Check if logo URL is a relative path, convert it to a full URL if so
if (!empty($logo) && !filter_var($logo, FILTER_VALIDATE_URL)) {
$parsedUrl = parse_url($row['url']);
$logo = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . '/' . ltrim($logo, '/');
}
?>
No records found.";
}
// Close database connection
$conn->close();
?>