Results 1 to 5 of 5

Thread: php with mysql

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    php with mysql

    i use php to insert data into my sql tables - using phpmyAdmin stuff

    but i have a big problem. when i insert stuff into the table, the new record should appear at the end of the table, instead everything is in some sort of order in the table

    i want all the newest records to appear at the end of the table

    why does it not insert at the end of the table

    whats the problem?

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: php with mysql

    When you query your table just sort it yourself, eg

    Code:
    SELECT * FROM your_table ORDER BY date DESC

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: php with mysql

    thanks for the reply mate, but there is no 'date' field :S

    i get:

    Query error
    Unknown column 'date' in 'order clause'

    $query = "SELECT * FROM `table` ORDER BY date desc";
    $result = mysql_query($query) or die("Query error<br/>" . mysql_error());
    $total_rows = mysql_num_rows($result);

  4. #4
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: php with mysql

    sorry misread data with date in your first post. Just order it by your primary key in your table.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: php with mysql

    Make sure you have an index (id) column with auto_increment set and then use last_insert_id() for that field's value whenever you add a new record.

Posting Permissions

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



Click Here to Expand Forum to Full Width