Jump to content

Data From MySQL database


herghost

Recommended Posts

Hi All,

 

I am trying to display data from a mysql table in PHP, the idea is the user can see information about themselves when they click on a link and change various things.

 

This is what I have so far:

 

<?php

require_once('dbconfig.php');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if(!$link) {

die('Failed to connect to server: ' . mysql_error());

}

 

 

   

mysql_select_db(DB_DATABASE);

 

//select the table

$result = mysql_query("select * from members");

 

//grab all the content

while($r=mysql_fetch_array($result))

{   

  //the format is $variable = $r["nameofmysqlcolumn"];

  //modify these to match your mysql table columns

 

  $firstname=$r["firstname"];

  $lastname=$r["lastname"];

  $login=$r["login"];

  $email=$r["email"];

 

  //display the row

  echo "<br />

<br />

<br />

<br />

 

Your First Name:  $firstname <br>

  Your Surname:  $lastname <br>

  Your Username:  $login  <br>

  Your Email Address:    $email ";

}

 

 

 

?>

 

Which works fine apart from one minor detail, It displays everything in the database :)

 

How can I change this just to display the users information? Each user is assigned a auto increment primary id in the database.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/147077-data-from-mysql-database/
Share on other sites

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.