If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > mySQL PHP display question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-14-11, 07:08
jamesyg jamesyg is offline
Registered User
 
Join Date: Oct 2011
Posts: 3
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"; }?>
Reply With Quote
  #2 (permalink)  
Old 10-14-11, 07:28
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 10-14-11, 07:39
jamesyg jamesyg is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 10-14-11, 08:24
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On