DeanWhitehouse Posted May 8, 2008 Share Posted May 8, 2008 this is my code <?php if (isset($_GET['image_id'])) { if ((int) $_GET['image_id'] > 0) { $imageid = $_GET['image_id']; $sql = "SELECT * FROM `hayleyimages` WHERE `image_id`='{$imageid}' LIMIT 0,1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $imageprofname = $row['image_name']; $imageprofcaption = $row['image_caption']; $imageproflink = $row['image_link']; echo "$imageprofname<br>$imageprofcaption<br>"; ?> <table align="center" border="1"><th>Image<?php echo "$imageprofname"; ?></th> <tr><td><?php echo ' <img src="'.$rows['image_link'].'"width="200px" /></a>'; ?></td><td><?php echo 'ID'.$rows['image_id'].''; ?></td></tr><td><?php echo ' <a href="'.$rows['image_link'].'" rel="lightbox" title="'.$rows['image_caption']. '" >'.$rows['image_name']. ' </a>'; ?></td><td><br /></td></tr> </table> <?php if (mysql_num_rows($result) < 1) { echo 'This ID does not exist in the database<br>'; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } exit(); } else { echo "Unknown Image ID! <br />"; echo "<a href=\"index.php\">Return to Image Page</a>"; exit(); } } //No ID passed to page, display user list: $query = "SELECT image_id, image_name, image_link, image_caption FROM `hayleyimages`"; $result = mysql_query($query) or die("Error:" . mysql_error()); if (mysql_num_rows($result) > 0) { while($rows=mysql_fetch_array($result)){ // Start looping table row ?> <table align="center" border="1"><th>Images</th> <tr><td><?php echo ' <a href="?image_id'.$rows['image_id'].'">'.$rows['image_name']. ' Details</a>'; ?></td><td><?php echo ' <a href="'.$rows['image_link'].'" rel="lightbox" title="'.$rows['image_caption']. '" >'.$rows['image_name']. ' </a>'; ?></td><td><?php echo ' <img src="'.$rows['image_link'].'"width="200px" /></a>'; ?><br /></td></tr> </table> <?php } if (mysql_num_rows($result) < 1) { echo "No Images To Display"; } } mysql_close(); ?> But this is not working, the page has a table with a dynamic link in it, this links address is http://hayley.awardspace.com?image_id(then the image id number) but when you click on the link it has the same content, it shouldn't. the URL changes in the address bar, but the page remains unchanged . any ideas? Quote Link to comment Share on other sites More sharing options...
Fadion Posted May 8, 2008 Share Posted May 8, 2008 Im re-writting your query, just to simplify it: $sql = "SELECT * FROM hayleyimages WHERE image_id=$imageid"; It doesnt need smart quotes (`), curly braces on a variable, single quotes on an int variable, LIMIT 0,1 can be written LIMIT 1, the LIMIT isnt needed as a where id=xx will return only one value (1 id for 1 row) and u dont need to have a semicolon in a query. Anyway it cant work as the fetched array returned by the database is assigned to $row and below ure using $rows['image_link'], $rows['image_id'] etc. Quote Link to comment Share on other sites More sharing options...
DeanWhitehouse Posted May 8, 2008 Author Share Posted May 8, 2008 just changed some of the variables, therefore fixed. Thanks for tidying up the code a bit. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.