Chidori Soul Posted June 12, 2009 Share Posted June 12, 2009 Ok, I am trying to make a User Profile, and I heard that you could just create one page, that shows what you need with reading the Table based on each user. Now, I just need to figure out how to do that, please help Quote Link to comment https://forums.phpfreaks.com/topic/161905-read-mysql-table-then-post-information/ Share on other sites More sharing options...
haku Posted June 12, 2009 Share Posted June 12, 2009 http://www.google.com/#hl=en&q=php+mysql+tutorial&aq=f&oq=&aqi=g10&fp=q07gBlqSm5s Quote Link to comment https://forums.phpfreaks.com/topic/161905-read-mysql-table-then-post-information/#findComment-854249 Share on other sites More sharing options...
Ken2k7 Posted June 12, 2009 Share Posted June 12, 2009 You probably want your DB tables to be set up like - Table users id PRI name . . . Table profilefields user_id PRI field1 field2 field3 . . . Tables are incomplete, but you get the idea. So in your PHP script, you can have a URL like http://domain.com/profile.php?id=1 where the id part is the ID of the user in the users table. Then you query the DB looking up the info you need in the profilefields table. Quote Link to comment https://forums.phpfreaks.com/topic/161905-read-mysql-table-then-post-information/#findComment-854255 Share on other sites More sharing options...
Chidori Soul Posted June 12, 2009 Author Share Posted June 12, 2009 haku: I am reading through a book about it right now, and that, but I can't seem to find the information I am looking for Ken2k7: I have the table set up, I just need to know how to read it then display the information gathered from the table. Quote Link to comment https://forums.phpfreaks.com/topic/161905-read-mysql-table-then-post-information/#findComment-854622 Share on other sites More sharing options...
ldougherty Posted June 12, 2009 Share Posted June 12, 2009 This is an example of how you would query a table and display the results. $result=mysql_query("SELECT * FROM mytable"); while ($row = mysql_fetch_array($result)) { $name = $row[name]; $age = $row[age]; echo "$name is $age year(s) old<br>"; } You would simply adjust the table name and values for columns you are looking to retrieve. Hopefully this points you in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/161905-read-mysql-table-then-post-information/#findComment-854643 Share on other sites More sharing options...
Chidori Soul Posted June 12, 2009 Author Share Posted June 12, 2009 Oh, Thanks! Now, I just need to know on how to make one page for each user, and have it add another ID for each user registered like this: profile.php?id=1 now, if ID 2 registers, they could click View Profile, and it would be: profile.php?id=2, and if ID 3 clicks it...etc Would this have to do with Cookies or Sessions? Quote Link to comment https://forums.phpfreaks.com/topic/161905-read-mysql-table-then-post-information/#findComment-854655 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.