jomok Posted January 8, 2013 Share Posted January 8, 2013 Can somebody help me out with a beginners PHP Quiz for School? "Use the information below to finish the input form. The user should be able to add a new name and email record into the account table and display the 10 newest records below the form." I have caught the increment typo and I think I got the form action. Is there anything I am missing? How do I get the 10 newest records to show below the form? Thanks class account{ function account(){ $this->id = ' '; $this->name = "; $this->email = "; } function find_account($id){ $sql="select ‘id‘ from ‘account‘ where ‘id‘='".$id."'"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)){ $row['id']; //int pk auto incerment increment $row['name']; //varchar(50) $row['email']; //varchar(50) $row['timestamp']; //varchar(15) } } } <htm|> <body> <div> <form action='#'> <form action="#" method="post"> name: <input type='text' name='account_name'> email:<input type='text' id='account_email'> <input type="button" value="submit"> </form> </div> <div style="border:solid 1px #F6O;"> Last 10 entry: </div> <div style="border:solid 1px #OOO;"> <?php echo "id: ".$account->id;?> <?php echo "name: ".$account->name;?> <?php echo "email: ".$account->email;?> </div> </body> </htm|> php_test.pdf Link to comment Share on other sites More sharing options...
Beeeeney Posted January 8, 2013 Share Posted January 8, 2013 Have you even attempted to do this on your own? Link to comment Share on other sites More sharing options...
jomok Posted January 8, 2013 Author Share Posted January 8, 2013 Yes Link to comment Share on other sites More sharing options...
sourcy Posted January 8, 2013 Share Posted January 8, 2013 ten newest records would look like: SELECT * FROM 'account' ORDER BY 'timestamp' LIMIT 10 Link to comment Share on other sites More sharing options...
Barand Posted January 8, 2013 Share Posted January 8, 2013 Well, that would give the 10 earliest. You would need ... ORDER BY timestamp DESC LIMIT 10 Link to comment Share on other sites More sharing options...
Christian F. Posted January 11, 2013 Share Posted January 11, 2013 sourcy: In addition to what Barand said. Field names are not escaped using single quotes in MySQL, but backticks. Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 11, 2013 Share Posted January 11, 2013 Locking this topic. The point of taking a quiz, even if it's an open book/open Internet quiz, is to test your ability, knowledge, and skills. Not to test ours. Besides, the quiz was probably over shortly after the OP posted this. Link to comment Share on other sites More sharing options...
Recommended Posts