Ok, so i have a form at http://openwar.net/php/test.php where user fills out the form and the information is placed in a database. Then the user can go to http://openwar.net/php/review.php so they can see what people have filled out the form. It displays the value in the field "first" in the table.
Then once they click the name it goes to a page that i cant figure out how to get it working. I want it to display all values in the field for the username that they select. For example, select steve and it will display everything steve filled out for the form.
Can anyone tell me how to get the information to display for the user selected. The link takes you to http://openwar.net/php/read.php?action=jackson where action=FIRSTNAME. So i want the values in the field where the first name = action to be displayed.
Thanks
steve
Getting form data to display
Moderator: General Moderators
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
Code: Select all
$query = "SELECT * FROM users WHERE firstname = '{$_GET['action']}'";How do i display the results tho (note im really new to mysql so the fact i even got the form to store the data was lucky for me)
Here is the code i have now for displaying the results of action=FIRST
Thanks
Steve
Here is the code i have now for displaying the results of action=FIRST
Code: Select all
<?
$username="";
$password="";
$database="";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT * FROM mac_form WHERE first = '{$_GETї'action']}'";
$result=mysql_query($query);
mysql_query($query);
echo "<b><center>Database Output</center></b><br><br>";
###HERE is where i want the info to be displayed
?>Steve
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
Ahh ok. For multiple results try:
And if you are only getting a single result from the database you dont need to add the code within a while loop and can simply use:
Code: Select all
...
$result=mysql_query($query);
while($row = mysql_fetch_assoc($result)){
echo $row['field_in_database'];
}Code: Select all
...
$row = mysql_fetch_assoc($result);
echo $row['field_from_database'];