if i clicked any name(link) from the user list , it ll show only the profile which contains the last row details in the database.
if i clicked the link of id=1 it will open the last id's profile !!!!!!!!!!!!!!
how to get the solution for this ?
User profiles
-
- Posts: 14
- Joined: Fri Nov 11, 2011 12:32 pm
- Location: India
Re: User profiles
<?php include 'connect.php'; $query = mysql_query("SELECT * FROM student"); $numrows = mysql_num_rows($query); if($numrows > 0) { while ($row = mysql_fetch_assoc($query)){ $id = $row['id']; $regno = $row['regno']; $name = $row['name']; } } ?> <html> <head> <title><?php echo $name; ?>'s profile</title> </head> <body> <div id="container"> <h1><?php echo $name; ?>'s profile</h1> <table> <tr><td>RegNo : <?php echo $regno; ?></td></tr> <tr><td>Name : <?php echo $name; ?></td></tr> </div> </body> </html>
Last edited by jacek on Mon Dec 26, 2011 2:55 pm, edited 1 time in total.
Reason: code tags...
Reason: code tags...
-
- Posts: 534
- Joined: Thu May 05, 2011 8:19 pm
Re: User profiles
Please edit your post and use the code tag button
Also, The reason is because you dont use any conditional operators in your SQL statement.
You need to tell it WHERE to look,
Change your query to accomodate for that.
Eg.
[syntax=php ][/syntax ]Thanks.
Also, The reason is because you dont use any conditional operators in your SQL statement.
You need to tell it WHERE to look,
Change your query to accomodate for that.
SELECT * FROM users WHERE id = $idIt is also worth noting that SELECT * (All) is bad technique, you should only select the fields that are necessary for you.
Eg.
SELECT `id`,`username`,`email` FROM `users` WHERE `id` = '{$_POST['id']}'
I don't like to brag, but I wasn't circumcised. I was circumnavigated.
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9