skip to Main Content

I got a Single File Website witch reads xlsx Files out of a directory, theen it generates a select menu out of it.

You can select a file and it gets displayed with SimpleXLSX

My problem is that i cant get the site scaled down to bee shown in full witdh, on my phone it gets zoomed in and a have to slace it back ddown manually.

Can someone helb me with this problme?

<?php

use ShuchkinSimpleXLSX;

ini_set('error_reporting', E_ALL & ~E_NOTICE);
ini_set('display_errors', true);


require_once __DIR__.'/simplexlsx/src/SimpleXLSX.php';


// Überprüfen, ob ein Dateipfad ausgewählt wurde
if (isset($_GET['file'])) {
    // Dateipfad in $fl speichern
    $fl = $_GET['file'];
}

$dir = './files'; // Pfad zum Ordner mit den Dateien
$fileList = glob($dir . '/*'); // Liest alle Dateien im Ordner ein

?>

<!DOCTYPE html>
<html lang="de">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>Lieferanzeige</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <style>
        body {
          font-size: 13px;
          font-family: "Open Sans", Arial, sans-serif;
          margin: 0;
          padding: 10px;
        }

        .geliefert {
          background-color: #b2f7d9;
        }

        select {
          width: 100%;
          padding: 10px;
          font-size: 20px;
          border: 1px solid #888;
          background-color: #f2f2f2;
          border-radius: 4px;
          box-sizing: border-box;
          margin-bottom: 10px;
        }

        table {
          border-collapse: collapse;
          width: 95%;
          margin-bottom: 20px;
        }

        th,
        td {
          padding: 8px;
          border: 1px solid #ddd;
          text-align: left;
          font-size: 14px;
        }

        th {
          background-color: #f2f2f2;
          font-weight: bold;
          color: #333;
        }

        .header {
          background-color: #ddd;
          font-weight: bold;
          color: #333;
        }

        @media only screen and (max-width: 599px) {
          table {
            width: 100%;
          }
          select {
            width: 100%;
          }
        }
    </style>
</head>
<body>
    <!-- HTML-Formular -->
    <form method="get">
        <select name="file" onchange="this.form.submit()">
            <option value="">Bestellung wählen</option> <!-- Erste Option -->
            <?php foreach ($fileList as $file) {
            $dateiname = basename($file);
            $filename = basename($file, '.' . pathinfo($file, PATHINFO_EXTENSION));
            if(substr($filename, -1) == 'H') {
                $filename = 'Herbst ' . substr($filename, 0, -1);
            } elseif(substr($filename, -1) == 'F') {
                $filename = 'Frühjahr ' . substr($filename, 0, -1);
            }
            // Option mit vollständigem Dateipfad als Wert und modifiziertem Dateinamen als Text
            echo '<option value="' . $dateiname . '">' . $filename . '</option>';
        } ?>        
        </select>
    </form>
    
    <?php if (isset($_GET['file'])) {?>
        <div class="head"> 
            <?php
                
                echo "Lieferstatus ";
                $flname = $fl;
                $flname = basename($flname, '.' . pathinfo($flname, PATHINFO_EXTENSION));
                if(substr($flname, -1) == 'H') {
                    echo $flname = 'Herbst ' . substr($flname, 0, -1);
                } elseif(substr($flname, -1) == 'F') {
                    echo $flname = 'Frühjahr ' . substr($flname, 0, -1);
                }
            ?>
        </div>
        
        <?php       
        $pfad = $dir."/".$fl;
        
        //Prüfen ob datei existiert
        if (!file_exists($pfad)) {
            echo "Ausgewählte Datei nicht vorhanden!";
            exit();
        }

        // Prüfen, ob es sich um eine XLSX-Datei handelt
        if (!preg_match('/.xlsx$/i', $pfad)) {
            echo "Kein XLSX File ausgewählt!";
            exit();
        }
        
        
        if ( $xlsx = SimpleXLSX::parse($pfad) ) {
            $pos = count($xlsx->rows());
            $pos = $pos-1;      
        
            echo "<b>".$pos."</b> Bestellpositionen in Datei: <b>".$fl."</b> gefunden!";
            echo '<table id="brshop">';
            $z=0;
            foreach ($xlsx->rows() as $r) {
                echo '<tr>';
                echo '<th class="' . (($z == 0) ? 'header' : (($r[4] != "xxx") ? 'geliefert' : '')) . '">' . (($z != 0) ? $z : '') . '</th>';
                echo '<th class="' . (($z == 0) ? 'header' : (($r[4] != "xxx") ? 'geliefert' : '')) . '">' . $r[0] . '</th>';
                echo '<th class="' . (($z == 0) ? 'header' : (($r[4] != "xxx") ? 'geliefert' : '')) . '">' . $r[1] . '</th>';
                echo '<th class="' . (($z == 0) ? 'header' : (($r[4] != "xxx") ? 'geliefert' : '')) . '">' . $r[3] . '</th>';
                echo '<th class="' . (($z == 0) ? 'header' : (($r[4] != "xxx") ? 'geliefert' : '')) . '">' . $r[5] . '</th>';
                echo '<th class="' . (($z == 0) ? 'header' : (($r[4] != "xxx") ? 'geliefert' : '')) . '">' . $r[6] . '</th>';
                echo '<th class="' . (($z == 0) ? 'header' : (($r[4] != "xxx") ? 'geliefert' : '')) . '">' . substr($r[4],0,11) . '</th>';

                echo '</tr>';
                $z++;
            }
            echo '</table>';
        } else {
            echo SimpleXLSX::parseError();
        }
        
    } // Ende if isset($_GET['file']
    ?>
</body>
</html>

I did ask google for help 🙂 but all i can find was viewport settings and i try them but still the same result.

2

Answers


  1. Chosen as BEST ANSWER

    i think i got it.

    i will test on more devices soon but on mine it works with fhis:

      <meta name="viewport" content="width=device-width">


  2. @grandd For that issue you need to check that in mobile devices font-sizes above 16px. also you need to check there is any section or content overlap on horizontally.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search