Jump to content
tonysoprano

Cum pot face sa printez imaginile din folderul Upload in tabel?

Recommended Posts

Posted

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.

Posted (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 by tonysoprano
completare
  • Moderators
Posted

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>

 

  • Upvote 3
  • Moderators
Posted

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.

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...