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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

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.