mcirl2 Posted February 25, 2008 Share Posted February 25, 2008 Hey, This is probably a very dumb post but I am really struggling with it and cant find much that is of help. The website I am building has profiles of users. However there will be about 20 users and each with their own profile. Each user has a unique userID. How can I create a hyperlink with will go to / display the current user profile. Is it something like this. localhost/userProfile.php?id=15 If anyone could help that would be great!! Thanks, Mike Quote Link to comment Share on other sites More sharing options...
elpaisa Posted February 25, 2008 Share Posted February 25, 2008 you may post some of your code to start with and help you! Quote Link to comment Share on other sites More sharing options...
mcirl2 Posted February 25, 2008 Author Share Posted February 25, 2008 <?php // Variables for navigating between previous and next record id $previd = $id -1; $nextid = $id +1; // Your database connection code $dbcnx = mysql_connect('localhost:', 'usern','pwd') or die("Error Occurred"); mysql_selectdb("iecoadventuredb"); $query = "SELECT * FROM users WHERE ID='$id'"; $result = mysql_query($query, $dbcnx); $row = mysql_fetch_array($result); // Checking and displaying data If (($id > 0) && ($id <= sizeof($row))) { echo $row['ID']; echo "<a href=\"page.php?id=$previd\">Previous</a> <a href=\"page.php?id=$nextid\">Next</a>"; } else { if ($id < 1) { echo "Beginning of Record Set"." "; echo "<a href=\"page.php?id=$nextid\">Next</a>"; } else { echo "End of Record Set"." "; echo "<a href=\"page.php?id=$previd\">Previous</a>"; } } ?> This is my code. It s very simple but when I click on the link nothing happens. I ahve tried changing the id in the address bar but nothing happens. If I hard code a value fromt he database it will work. Any ideas what Im doing wrong. The whole page.php?id=3 thing baffles me. What is the id?? where does it come from? Thanks for the help! Mike Quote Link to comment Share on other sites More sharing options...
deansatch Posted February 25, 2008 Share Posted February 25, 2008 Try changing : $previd = $id -1; $nextid = $id +1; to: $previd = $_GET['id'] -1; $nextid = $_GET['id']+1; Quote Link to comment Share on other sites More sharing options...
mcirl2 Posted February 25, 2008 Author Share Posted February 25, 2008 fixed it! Cheers for that!! 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.