computermax2328 Posted May 28, 2012 Share Posted May 28, 2012 Hello all, I am having trouble creating an $ID variable. Here is the deal, I am building a universal profile.php page where all of the data from my data tables will fall into that template, for example First Name: [$firstname]. The problem is that the $ID for these pages is not generated by a session. I need the site visitor to click a link and be directed to this profile.php. My problem is that I cannot figure out the link for the user to click and identify the $ID of the link that they clicked from my database. Does anyone know the answer or have a better build suggestion?? Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/ Share on other sites More sharing options...
Barand Posted May 28, 2012 Share Posted May 28, 2012 hover your mouse pointer over your name above and look at the link in the status bar at bottom Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/#findComment-1349240 Share on other sites More sharing options...
mrMarcus Posted May 28, 2012 Share Posted May 28, 2012 http://www.your-site.com/profile.php?id=123 Where 123 is the ID of the corresponding profile. Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/#findComment-1349241 Share on other sites More sharing options...
computermax2328 Posted May 28, 2012 Author Share Posted May 28, 2012 Right, but im not really sure what the "id of those corresponding profiles" is. In my MYSQL database I have auto incrementing id numbers and last names, which is what I will id them by. How do I select that as the id in the corresponding link to the profile? For example link to Max Baldwin's profile. Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/#findComment-1349274 Share on other sites More sharing options...
mrMarcus Posted May 28, 2012 Share Posted May 28, 2012 Right, but im not really sure what the "id of those corresponding profiles" is. In my MYSQL database I have auto incrementing id numbers and last names, which is what I will id them by. How do I select that as the id in the corresponding link to the profile? For example link to Max Baldwin's profile. In basic form, if Max Baldwin's ID in the db table is 547 then the link would be (something like): http://www.your-site.com/profile.php?id=547 And on profile.php you would grab that ID from the URL and shove it in a query. Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/#findComment-1349277 Share on other sites More sharing options...
computermax2328 Posted May 28, 2012 Author Share Posted May 28, 2012 Alright, I think I understand it. Let me give it a shot and I will report back. Thanks again guys! Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/#findComment-1349296 Share on other sites More sharing options...
computermax2328 Posted May 28, 2012 Author Share Posted May 28, 2012 I just wanted to thank everyone for the help they have given me so far, but..... The suggestion I was given was to use the following link on my website... www.mywebsite.com/profile.php?id=1 If I were to use this link I would have to input all of the code to the links like so.... <a href=http://www.mywebsite.com/profile.php?id=1><p>user's name<p><a> Is there a way so I do not have to do this link for all of my 151 pages on a master profile list page? Again, let me just fill you in, users are not making theses pages. I am creating these pages from the back end and I am using a standard profile.php. These pages are profiles of people that I am creating. There are no sessions! Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/#findComment-1349343 Share on other sites More sharing options...
Barand Posted May 28, 2012 Share Posted May 28, 2012 Generate the list from your database $sql = "SELECT id, lastname FROM profile ORDER BY lastname"; $res = mysql_query($sql); while (list($id, $name) = mysql_fetch_row($res)) { echo "<a href='profile.php?id=$id' >$name</a><br/> } Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/#findComment-1349347 Share on other sites More sharing options...
computermax2328 Posted May 30, 2012 Author Share Posted May 30, 2012 Thank you for this help. Could you explain how you set the $ID and $name variables? Thanks again, Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/#findComment-1349804 Share on other sites More sharing options...
Jessica Posted May 30, 2012 Share Posted May 30, 2012 in his example he used list, did you read what it does? Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/#findComment-1349814 Share on other sites More sharing options...
computermax2328 Posted May 30, 2012 Author Share Posted May 30, 2012 Ooo got it. That is a handy function Quote Link to comment https://forums.phpfreaks.com/topic/263274-user-page-id-trouble/#findComment-1349825 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.