tonysoprano Posted March 9, 2022 Report Posted March 9, 2022 am urmatorul script: <div class="table-responsive"> <table class="table table-hover table-dark"> <thead> <tr> <th scope="col">Nume</th> <th scope="col">Prenume</th> <th scope="col">Adresa</th> </tr> </thead> <tbody> <?php if(file_exists("log.txt")){ $bin = file_get_contents("log.txt"); $bin = explode("\n", $bin); foreach($bin as $bins) { $bins = explode("|", $bins); $Nume = $bins[0]; $Prenume = $bins[1]; $Adresa = $bins[2]; if($Nume == "") { }else{ echo "<tr> <td>".$Nume."</td> <td>".$Prenume."</td> <td>".$Adresa."</td> > </tr>"; } } }else{ echo "<tr><td>Oops :(</td><td></td><td></td></tr>"; } ?> cum pot sa fac la fiecare coloana de tabel sa mi printeze si imaginile din folderul Upload atunci cand un user se inregistreaza? am acest cod da nu stiu cum sa l integrez in scriptul de mai sus. $dirname = "upload/"; $images = glob($dirname."*"); foreach($images as $image){ echo '<a href="'.$image.'" target="_blank"><br><img src="'.$image.'" height="100" width="100" /></a> <br>==============='; } Sper sa ma fi facut inteles, imi cer scuze daca am omis ceva sunt inca incepator. Multumesc anticipat. Quote
Moderators Dragos Posted March 9, 2022 Moderators Report Posted March 9, 2022 Ce incerci sa faci mai exact? Scriptul listeaza datele intr-un tabel. Cum sunt datele astea legate de pozele din upload? Ai vreun identificator comun? Quote
tonysoprano Posted March 9, 2022 Author Report Posted March 9, 2022 (edited) <h2>Imagini</h2> <div class="table-responsive"> <table class="table table-hover table-dark"> <tbody> <?php $working_dir = getcwd(); //get image directory $img_dir = $working_dir . "/upload/"; //change current directory to image directory chdir($img_dir); //using glob() function get images $files = glob("*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}", GLOB_BRACE ); //again change the directory to working directory chdir($working_dir); //iterate over image files foreach ($files as $file) { ?> </td><td><a href="<?php echo "upload/" . $file ?>" target="_blank"><img src="<?php echo "upload/" . $file ?>" style="height: 100px; width: 100px;"/></a></td></tr> <?php } ?> </tbody> </table> Deci toate pozele din folderul Upload vreau sa le puna in tabel la fiecare user in parte care adauga poze, am gasit scriptul de mai sus dar nu stiu cum il integra la scriptul care pune numele si adresa la useri Sau daca se poate sa mi adauge alt rand in tabel cand se adauga imagini noi in folderul Upload Edited March 9, 2022 by tonysoprano completare Quote
Moderators Dragos Posted March 9, 2022 Moderators Report Posted March 9, 2022 Iti trebuie o ancora/legatura, ce user are ce poza. De exemplu, in fisierul tau text, poti sa ai ceva de genul Georgescu|Marcel|Bucuresti|poza1.jpg Popescu|Vasile|Cluj-Napoca|poza2.jpg Mateescu|Cornel|Constanta|poza3.jpg Pozele sunt salvate in folderul uploads, ca sa le afisezi poti avea ceva de genul <div class="table-responsive"> <table class="table table-hover table-dark"> <thead> <tr> <th scope="col">Nume</th> <th scope="col">Prenume</th> <th scope="col">Adresa</th> </tr> </thead> <tbody> <?php if(file_exists("log.txt")) { $bin = file_get_contents("log.txt"); $bin = explode("\n", $bin); foreach($bin as $bins) { $bins = explode("|", $bins); echo "<tr><td>$bins[0]</td><td>$bins[1]</td><td>$bins[2]</td><img src='uploads/$bins[3]'></td></tr>"; } }else{ echo "<tr><td colspan='4'>Oops :(</td></tr>"; } ?> </tbody> </table> </div> 3 Quote
tonysoprano Posted March 9, 2022 Author Report Posted March 9, 2022 OK, si daca in folderul Upload sunt 40 de imagini cum stie care este imaginea adaugata de Georgescu? Imaginile se pun cu numee aleatorii in folderul Upload. Quote
Moderators Dragos Posted March 9, 2022 Moderators Report Posted March 9, 2022 Cand un user uploadeaza o poza, poti sa pui in baza de date sau in fisierul text ce nume i s-a generat la poza. Trebuie sa mentii o legatura ce user are ce poza. 1 Quote