Results 1 to 2 of 2

Thread: Custom PHP Code - A little stuck. Need some assistance

  1. #1
    Join Date
    Aug 2008

    Custom PHP Code - A little stuck. Need some assistance

    I'm working with a client and setting up this form for them. I'm trying to have the user be able to add a new name and email record into the account table. Once they submit it should display the 10 newest records below the form. Appreciate any help.

    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
    $row['name']; //varchar(50)
    $row['email']; //varchar(50)
    $row['timestamp']; //varchar(15)
    <form action='#'>
    name: <input type='text' name='account_name'>
    email:<input type='text' id='account_email'>
    <input type="button" value="submit">
    <div style="border:solid 1px #F60;">
    Last 10 entry:
    <div style="border:solid 1px #000;">
    <?php echo "id: ".$account->id;?>
    <?php echo "name: ".$account->name;?>
    <?php echo "email: ".$account->email;?>

  2. #2
    Join Date
    Feb 2012
    Pensacola, FL
    Here is one of about 1,000,000 ways to do it.

    PHP Code:
    class account{
     function account(){
      $this->id = ' ';
      $this->name = '';
      $this->email = '';
     function find_account(){
      $sql="SELECT `id`,`name`,`email`,`timestamp` FROM `account` ORDER BY id DESC LIMIT 10";
      $result = mysql_query($sql);
      while($row = mysql_fetch_assoc($result)){
       foreach($row as $r => $v){
        $return[][$r] = $v;
      return $return;

    <form action='?'>
    name: <input type='text' name='account_name'>
    email:<input type='text' id='account_email'>
    <input type="button" value="submit">
    <div style="border:solid 1px #F60;">
    Last 10 entry:
    <div style="border:solid 1px #000;">
    = new account();
    $lastten $accounts->find_account();
    $lastten[$i]['id'].' | '.$lastten[$i]['name'].' | '.$lastten[$i]['email'].'<br/>';

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center