Jump to content

Read MySQL Table then post information


Chidori Soul

Recommended Posts

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.

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.

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.