Urfahranermarkt Linz

Aussteller test

🐘
filename.php
<?php

$servername = "localhost";
$username = "d0362688";
$password = "ntXVYQ4kwcNJxNM2WWaR";
$dbname = "d0362688";

function logo($l){ // --------------------------------Logo einblenden wenn vorhanden
    if ($l != ""){
        $alttext = "Logo von " . $row[2];
        $title = "Logo: " . $row[2];
    }else{
        $l = "no-logo.png";
        $alttext = "Kein Logo vorhanden";
        $title = "Kein Logo vorhanden";
    }
    return $l;
}

function extlink($l,$was){ // ------------------------------------------Links einbinden
    if($l != ''){
    if($was == 'Homepage') {$art = 'https://';}
    if($was == 'Email') {$art = 'mailto:';}
        echo '<a href="'.$art.$l.'" target="_blank" style="padding:3px 5px 3px 5px; 
                        border:1px #C6297640 solid; border-radius:8px; margin:10px;">'.$was.'</a>';
    }
}
// -------------------------------------------------------------------------- Standort def -----
$standort = '';
$sqladd = '';
$standort = htmlspecialchars(strip_tags($_GET['standort']));
$suche = htmlspecialchars(strip_tags($_GET['suche']));

if($standort!= ''){ // --------------------------------------------------- Standort für sql
$sqladd = "AND (standort = '".$standort."')";
}
if($suche!= ''){ //--------------------------------------------------------Suchbegriff für sql
$sqladd .= " AND (name LIKE '%".$_GET['suche']."%' OR standort LIKE '%".$_GET['suche']."%'
OR adresse LIKE '%".$_GET['suche']."%' OR beschreibung LIKE '%".$_GET['suche']."%')";
}
?>

<form name="formular" method="get">
    <label for="standort">Auswahl Standort:</label>
    <select name="standort">
        <option value="" <?php if ($standort == "") echo "selected"; ?>>Alle</option>
        <option value="Halle A" <?php if ($standort == "Halle A") echo "selected"; ?>>Halle A</option>
        <option value="Halle B" <?php if ($standort == "Halle B") echo "selected"; ?>>Halle B</option>
        <option value="Halle C" <?php if ($standort == "Halle C") echo "selected"; ?>>Halle C</option>
        <!--<option value="Donaualm" <?php if ($standort == "Donaualm") echo "selected"; ?>>Donaualm</option>-->
        <option value="Freigelände Ost" <?php if ($standort == "Freigelände Ost") echo "selected"; ?>>Freigelände Ost</option>
        <option value="Freigelände West" <?php if ($standort == "Freigelände West") echo "selected"; ?>>Freigelände West</option>
        <option value="Konsumation" <?php if ($standort == "Konsumation") echo "selected"; ?>>Konsumation</option>
        <option value="Schausteller" <?php if ($standort == "Schausteller") echo "selected"; ?>>Schausteller</option>
        <option value="Wildbergstraße" <?php if ($standort == "Wildbergstraße") echo "selected"; ?>>Wildbergstraße</option>
        <option value="MarktAlm" <?php if ($standort == "MarktAlm") echo "selected"; ?>>Linzer MarktAlm</option>
    </select>

    <label for="suche">Suchbegriff</label>
    <input type="text" name="suche" placeholder="Suche" value="<?php echo $suche; ?>">
    <button type="submit" style="margin:20px 0 10px 0;">Suchen</button>
</form>

<?php
$conn = mysqli_connect($servername, $username, $password, $dbname);

if (!$conn) {
    die("Verbindung fehlgeschlagen: " . mysqli_connect_error());
}
mysqli_set_charset($conn, "utf8");
$sql = "SELECT standort, standort2, name, adresse, beschreibung, link, mail, logo, facebook, insta
        FROM ufm2021 WHERE standort<>'MarktAlm' and (link<>'' or mail<>'') " . $sqladd . " ORDER BY name LIMIT 0,300";

$result = mysqli_query($conn, $sql);
$anzahl = mysqli_num_rows($result);

if ($anzahl > 0) {
    echo '<p>Es wurden ' . $anzahl . ' Einträge gefunden.<br> </p>';
} else {
    echo '<p>Es wurde leider kein Eintrag gefunden.<br> </p>';
}

while ($row = mysqli_fetch_row($result)) {
    // if (strstr($row[5], '@')) {
    //     list($row[5], $row[6]) = array($row[6], $row[5]);
    // }  // --------- email und link tauchen

    $link = $row[5];
    $mail = $row[6];
    $face = $row[8];
    $insta = $row[9];

    if(strstr($link, '@')){
        $link = $row[6];
        $mail = $row[5];
    }

    if (strstr($face, 'insta')) {
        $face = $row[9];
        $insta = $row[8];
    }

    echo '<article style="padding:0.25rem; width:100%; display:flex; border-bottom: 1px #aaaaaa88 solid;">';
    echo '<div style="width:180px; padding: 0.25rem;">';
    echo '<img style="width:160px;" title="' . $title . '" alt="' . $alttext . '" src="/ausstellerdaten/' . logo($row[7]) . '">';
    echo '</div>';
    echo '<div style="width:100%; padding-left:0.25rem; padding-bottom:0.25rem;">';
    echo '<p style="margin:0px; padding:0px; padding-top:0.25rem"><span style="font-size:1.25rem; padding-right:2rem;">' . $row[2] . ' </span>' . $row[0] . ' ' . $row[1] . '</p>';
    echo '<p style="margin:0px; padding:0px;">' . $row[3] . '</p>';
    echo '<p style="margin:2px; padding:2px; font-style: italic;">' . $row[4] . '</p>';
    echo '<p style="margin:2px; padding:2px;">' . extlink($link, "Homepage") . ' ' . extlink($mail, "Email") . ' ' .
        extlink($face, "facebook") . ' ' . extlink(insta, "Instagram") . '</p>';
    echo '</div>';
    echo '</article>';
}
mysqli_close($conn);
?>