• User Attivo

    problema $offset

    <?php
    session_start();
    ?>
    <html>
    <head>
    <body onLoad="setTimeout('document.step1.submit();', 3000);">
    <form name="step1" action="step1.php" method="get">
    <title>Step1foto</title>
    </head>
    <?php

    $connessione=mysql_connect('localhost', );
    $selezione_db=mysql_select_db("guest_book", $connessione);
    $query = mysql_query("SELECT id_user, date FROM messaggi ORDER BY date DESC limit 1");

    while($riga = mysql_fetch_assoc($query))
    {
    $id_user = $riga['id_user'];
    echo $riga["id_user"];
    }
    $nr_immagine = ($id_user - 1) * 10 + 1 + $offset; $directory = "C:\Programmi\EasyPHP1-8\www\fotos";
    $image_src = $directory . "image" . $nr_immagine . ".jpg";
    echo "<img src="$image_src">";
    if($offset < 50) {
    $offset++; }
    ?>
    <?php
    $_SESSION['user'] = $_GET['user'];
    $_SESSION['gender'] = $_GET['gender'];
    $_SESSION['year'] = $_GET['year'];
    $_SESSION['month'] = $_GET['month'];
    $_SESSION['day'] = $_GET['day'];
    $_SESSION['country'] = $_GET['country'];
    ?>
    </body>
    </html>

    Notice: Undefined variable: offset in c:\programmi\easyphp1-8\www\step1foto.php on line 24
    Notice: Undefined variable: offset in c:\programmi\easyphp1-8\www\step1foto.php on line 28
    Notice: Undefined variable: offset in c:\programmi\easyphp1-8\www\step1foto.php on line 29


  • User Attivo

    ciao,

    while($riga = mysql_fetch_assoc($query))
    {
    $id_user = $riga['id_user'];
    echo $riga["id_user"];
    }
    $nr_immagine = ($id_user - 1) * 10 + 1 + $offset; $directory = "C:\Programmi\EasyPHP1-8\www\fotos";
    $image_src = $directory . "image" . $nr_immagine . ".jpg";
    echo "<img src="$image_src">";
    if($offset < 50) {
    $offset++; }

    vorrei far si che si richiamino delle immagini che sono in : "C:\Programmi\EasyPHP1-8\www\fotos numerate da 1 a 10 in base al numero di id_user di ciascun utente.

    vorrei che per l'utente con id_user = 1,11,21,31,41...ecc venissero richiamate le foto di questa directory, mentre per quelli con id_user 2,22,32,42...ecc, una seconda directory di foto
    e cosi' via per tutti i numeri da 0 a 9.


  • Moderatore

    Non sono a casa ed al lavoro non posso testare php ma prova a fare il modulo 10 dell'id utente.
    Qualcosa tipo
    Nome cartella = (string)idUtente%10; 🙂


  • User Attivo

    :ciauz: non ho capito cosa mi consigli di preciso.:?