View Single Post
  #3  
Old 05-13-2008, 02:32 AM
Phouber Phouber is offline
Corporal
 
Join Date: May 2008
Posts: 10
Default Re: How to display database records on screen?

Well heres a nice code that should work for displaying a users data.
PHP Code:
function displayUsersData($username$table) {
 
$con connect() // <--- THIS LINE IS JUST FOR THE CODE, REPLACE IT WITH YOUR DB CONNECTION
 
$query "SELECT * FROM " .$table" WHERE username='$username'"//SELECTS ALL INFO FROM THE DB WHERE THE USERNAME IS THE USERS USERNAME, thats weird to say
 
$result mysql_query($query$con) or die(mysql_error()); //THE QUERY
 
while($data mysql_fetch_array($result)){
  echo 
$data['email']; //This will echo the row in the database called email, replace this with whatever row you want and you can add more lines, see below
  
echo $data['id']; //And more
  
echo $data['something']; //And so on...
 
}
}
//TO CALL THE FUNCTION
displayUsersData($username$table_name); //Replace with your values 
Does this answe your question?
Reply With Quote