Jump to content
xisto Community
Sign in to follow this  
apple

A Very Simple Album Problem, Help Needed.

Recommended Posts

Hey, I created a page album.php, it shows all the images of a user xxx. and its url is like album.php?nick=xxx. Now suppose there are 2 images in this user album, one image id is 111 and second image id is 112.now how i can link to the each image of the album so that it looks like , album.php?nick=xxx&image_id=111. and album.php?nick=xxx&image_id=112.I hope you understand it.

Share this post


Link to post
Share on other sites

Can you show us some code please? We can help you, but we need to see what you have available for information to use. For instance, are you storing the filenames in a database or picking them up using a readdir()? See what I mean?The answer will depend on several things, the code will provide us the clues needed to help you solve the problem.

Share this post


Link to post
Share on other sites

here's the code.

<?ob_start();include("config.php");if (!$_GET[nick]){$getuser = mysql_query("SELECT * from users order by id asc");while ($user = mysql_fetch_array($getuser)){echo ("<a href=\"album1.php?nick=$user[username]\">$user[username]</a><br />\n");}}ELSE{$getuser = mysql_query("SELECT * from pictures where username = '$_GET[nick]'");$usernum = mysql_num_rows($getuser);if ($usernum == 0){echo ("User Not Found");}else{while ($row = mysql_fetch_array($getuser)) {echo "<a href='funnypics/$row[link]' target='_blank'><img src=funnypics/$row[link] width='200px'></a><br>";}}}?>

Share this post


Link to post
Share on other sites

Here is a code snippet that will work.Do the mysql call and build the links as per your previous posting.

<?phpif (isset( $_GET['pix'] )) {   echo 'create the specific image here<br /><br />';   echo 'create link for the nick and the start pages here<br /><br />';   echo '<a href="LOCALHOST/image%20code%20test.php?nick=1" > nick1 </a><br /><br />';   echo '<a href="LOCALHOST/image%20code%20test.php" > start over </a>';   }   else if ( isset($_GET['nick'] )) {   		echo 'display image gallery for nick here<br /><br />';		echo 'create list of specific images here<br /><br />';		echo '<a href="LOCALHOST/image%20code%20test.php?nick=1&pix=1" > image1 </a><br /><br />';		echo '<a href="LOCALHOST/image%20code%20test.php?nick=1&pix=2" > image2 </a><br /><br />';		echo '<a href="LOCALHOST/image%20code%20test.php?nick=1&pix=3" > image3 </a><br /><br />';		echo '<a href="LOCALHOST/image%20code%20test.php?nick=1&pix=4" > image4 </a>';                echo '<a href="LOCALHOST/image%20code%20test.php" > start over </a>';   	  } else {           echo 'create list of links for nicks here<br /><br />';		   echo '<a href="LOCALHOST/image%20code%20test.php?nick=1" > nick1 </a><br /><br />';		   echo '<a href="LOCALHOST/image%20code%20test.php?nick=2" > nick2 </a><br /><br />';		   echo '<a href="LOCALHOST/image%20code%20test.php?nick=3" > nick3 </a><br /><br />';           }?>

Just add the "pix= x " to the anchor tags in the centre if/else codeblock and it should work marvellously for you. You may want to do a check to confirm that the files exist before you make the links, using the is_file() function. Let us know if you need any more information.Don't forget to finish the ob_start() and close the database. PHP takes care of all that, I know, but attention to detail makes a difference sometimes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.