Jump to content

Php Gallery


SleepTight

Recommended Posts

Hello, I have been trying to make this work for a while but nothing gives.

 

I'm a bit of a PHP noob, but not even a teacher at school could help me.

 

 

What I need is something like this page: http://marcandshawn.glrdmd.eu/ian/designers2.php?d=2

 

So when you click on a thumbnail, you see the bigger image above it, but stay on the same page.

 

 

My code:

 

<?php 
include('connection.php'); 
$query="SELECT * FROM person";
$result=mysql_query($query);                        
?> 

 

^ reestablishing connections.

 

some html after that.

and for the chosen main image:

    <?php 
while($row = mysql_fetch_array( $result )) {  
	echo "<img src='uploads/$row[image1]' style='max-width:300px;'/>"; 
    }  
	?>

 

^ doesn't work. row[image1] contains the images.

 

 

    <?php 
 {  
 	while($row = mysql_fetch_array( $result )){
		echo "<a href='index.php?id=$row[id]' style='width:100px; height:100px;'/><img src='uploads/$row[thumb]' style='width:125px; height:90px; border:0px;' /></a>"; 
	}		
    }  
	?>	   

 

Supposed thumbnails.

 

If someone could help, it would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/220487-php-gallery/
Share on other sites

A basic example of the logic behind that process:

 

if( isset($_GET['s']) && !empty($_GET['s']) ) {
switch ($_GET['s']) {
case 1:
	echo "<img src=\"image1.jpg\" title=\"Image1\"><br>";
	break;
case 2:
	echo "<img src=\"image2.jpg\" title=\"image2\"><br>";
	break;
default:
	echo "<img src=\"default.jpg\" title=\"default image\"><br>";
}
} else {
echo "<img src=\"default.jpg\" title=\"default image\"><br>";
}
?>

<!--  LINKS FROM THUMBNAILS -->
<a href="?s=1"><img src="thumb1.jpg"></a><br>
<a href="?s=2"><img src="thumb2.jpg"></a>

Link to comment
https://forums.phpfreaks.com/topic/220487-php-gallery/#findComment-1142363
Share on other sites

Not exactly what I wanted, but it works. At least i'm getting somewhere now. Thanks!

 

The problem is, I have to type each thumbnail individually, and to change it I must edit the php file.

 

What I want is that it grabs the images from the database, and where I can simply adjust the order and amount there.

Link to comment
https://forums.phpfreaks.com/topic/220487-php-gallery/#findComment-1142405
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.