Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2011
    Posts
    3

    Unanswered: mySQL PHP display question

    Hi there wondering if anyone can help me, I new to mysql and php and in really stuck...

    Basically I have created a profile system that you have to register your account details eg username and password. These then go onto a database in MySQL. Once you have registered you then get the opportunity to then complete a profile form. This form has details like name, passport info, frequent flyer info etc.

    This will then save into another separate MySQL database. Once the data is entered you then get taken back to the main screen.

    The main screen has an option to amend the details you just entered and this is where my problem begins.

    I would like to show just the record you have entered into the database but my coding displays all the other records in the database. I cannot figure out how to just display the ‘id’ I have just created.

    I have attached my coding below, any help would be really appreciated as I’m beginning to pull out whatever hair I have left!

    Thanks

    James



    include("connect.php");

    $query = "SELECT * FROM profile ";
    $result = mysql_query($query);
    $num = mysql_num_rows ($result);
    mysql_close();

    if ($num > 0 ) {
    $i=0;
    while ($i < $num) {
    $first_name = mysql_result($result,$i,"first_name");
    $surname = mysql_result($result,$i,"surname");
    $company_email = mysql_result($result,$i,"company_email");
    $mobile_number = mysql_result($result,$i,"mobile_number");
    $ba_number = mysql_result($result,$i,"ba_number");
    $id = mysql_result($result,$i,"id");

    echo "<b>first name:</b> $first_name<br>";
    echo "<b>surname:</b> $surname<br>";
    echo "<b>company email:</b> $company_email<br>";
    echo "<b>mobile number:</b> $mobile_number<br>";
    echo "<b>ba number:</b> $ba_number<br>";
    echo "<a href=\"update.php?id=$id\">Update</a> - <a href=\"delete.php?id=$id\">Delete</a>";
    echo "<br><br>";

    ++$i; } } else { echo "The database is empty"; }?>

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so put a where clause on the select that restricts what is retrieved from the db eg:-
    Code:
    SELECT my, comma, separated, column, list FROM mytable
    WHERE userid = 'jamesyg';
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Oct 2011
    Posts
    3
    thanks for your quick reply,

    won't that just show my 'profile' ? What I want to do is say you log on and create a user then you updated your profile. you then change ur passport number in 3 months, you then have to log back on and update your details.

    I need the user to log back in (which I can do) then click on update my records and it then will show all his info, he then changes it and bob is your aunty and it gets change.....

    arrrghh I sounds so simple but my small napper can't work out how to do it?

    cheers
    James

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    yes
    but that was an example
    replace the 'jamesyg' with the user id of the person who's details you want to show, presumably registered somewhere when the user logged on. bear in mind some legislations require authorisation from the user to put cookies on their PC. it may be smarter to create a session

    you need to find a mechanism to pass the userid (or authentication ID) from script to script.

    incidentally I'd be very wary of demanding a user's passport number and other such details as unless you can justify needing 'em you wouldn't get 'em from a cynic like myself. likewise if you are collecting personal data there may well be legal implications in the jurisdiction your server "lives in". fer instance if you were within the UK you would have to register with the Data Protection Registrar. you also need to make certain that such personal information is adequately protected whilst stored and being pumped up or down the network.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •