Smee Posted June 6, 2010 Share Posted June 6, 2010 Hi, I am trying to create a short list of new members that have registered to a site in PHP. This is what i have so far and i am getting an 'Undefined index: first_name' error. If i am right in thinking i need an (isset($_POST['??']) command somewhere in my code. If someone can point me in the right direction i'd be much appreciated. Cheers <?php require_once ('../mysql_connect.php'); $result = mysql_query("SELECT 3 FROM users ORDER BY user_id"); echo "<table border='0'> <tr> <th>First Name</th> <th>Post Code</th> <th>Team Supported</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['first_name'] . "</td>"; echo "<td>" . $row['post_code'] . "</td>"; echo "<td>" . $row['team_supported'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/204022-isset-command/ Share on other sites More sharing options...
ram4nd Posted June 6, 2010 Share Posted June 6, 2010 Select in the query is the column names that you select not the nr of items. $_POST is for sending data from browser to php. Not what you need. Use single quotes for php and doubles for html, what is wrong with you ppl i am seeing it everywhere. Quote Link to comment https://forums.phpfreaks.com/topic/204022-isset-command/#findComment-1068572 Share on other sites More sharing options...
kenrbnsn Posted June 6, 2010 Share Posted June 6, 2010 What are you trying to get using this query: SELECT 3 FROM users ORDER BY user_id Maybe you want SELECT * FROM users ORDER BY user_id or SELECT first_name, post_code, team_supported FROM users ORDER BY user_id Ken Quote Link to comment https://forums.phpfreaks.com/topic/204022-isset-command/#findComment-1068574 Share on other sites More sharing options...
Smee Posted June 6, 2010 Author Share Posted June 6, 2010 Of course it is i was thinking of something else at the time. It works fine but what i was trying to do by using a 3 would be only to show three results and for it to list these by highest user_id first. I was thinking something like this but it shows the lowest user_id first rather than last. $result = mysql_query("SELECT first_name, post_code, team_supported FROM users ORDER BY user_id LIMIT 3"); Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/204022-isset-command/#findComment-1068579 Share on other sites More sharing options...
Smee Posted June 6, 2010 Author Share Posted June 6, 2010 Think i have got it. I added a DESC after user_id. Thanks for your help. $result = mysql_query("SELECT first_name, post_code, team_supported FROM users ORDER BY user_id DESC LIMIT 5"); Quote Link to comment https://forums.phpfreaks.com/topic/204022-isset-command/#findComment-1068581 Share on other sites More sharing options...
ngoweb Posted June 6, 2010 Share Posted June 6, 2010 Removed - Wrong Post Quote Link to comment https://forums.phpfreaks.com/topic/204022-isset-command/#findComment-1068582 Share on other sites More sharing options...
kenrbnsn Posted June 6, 2010 Share Posted June 6, 2010 ngoweb: why did you post this? It is not related to the question at all? Ken Quote Link to comment https://forums.phpfreaks.com/topic/204022-isset-command/#findComment-1068583 Share on other sites More sharing options...
ngoweb Posted June 6, 2010 Share Posted June 6, 2010 oops! Sorry wrong post - me bad! - two many windows open Quote Link to comment https://forums.phpfreaks.com/topic/204022-isset-command/#findComment-1068586 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.