#1
  1. No Profile Picture
    fantom
    Guest
    Devshed Newbie (0 - 499 posts)
    Ok, I have 2 tables in my database, and I'm adding entries to them like every day or so, and I want to know how can I print the newest additions to the database (for say, last week, or even better - using cookies, since the last visit) on the front page, and for each table too...?
    Anyone know the syntax for that, cuz I'm really new to all this mySQL stuff.
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    If you don't have some sort of date field, you can't.

    This question is way to general. You need to tell us your table schema.
  4. #3
  5. No Profile Picture
    fantom
    Guest
    Devshed Newbie (0 - 499 posts)
    That's what I thought, without a date field it can't be done...
    let me see if I can add the date in database and I'll get back to you guys..
  6. #4
  7. No Profile Picture
    fantom
    Guest
    Devshed Newbie (0 - 499 posts)
    Ok, I gave up on that date function for the time being... but I have another task:

    If my table looks like this:
    ---------------------
    id|filename|url|size
    ---------------------
    and I want to pull out the total number of entries from that table (the highest ID), what should I do, what would the syntax be?
  8. #5
  9. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    The highest ID and the number of rows (entries) may or may not be the same thing. If you want the highest ID use:

    select max(id) as max_id from tablename;

    If you want the number of records:

    select count(*) as num_rec from tablename;

  10. #6
  11. No Profile Picture
    fantom
    Guest
    Devshed Newbie (0 - 499 posts)
    Shoot, I messed up something... how do I add that to my PHP3 files (regular HTML)...

    I have all my database info (name, password, tablename) stored in the config.inc file already, that is included in the PHP file, and how do I print this with the rest of the HTML code now?

    I can't just go
    echo "select count(*) as num_rec from tablename";

    [This message has been edited by fantom (edited October 01, 2000).]
  12. #7
  13. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?php
    $result = mysql_query("select count(*) as num_rec from tablename");
    $row = mysql_fetch_array($result);
    echo "The total number of entries is " . $row["num_rec"];
    ?>
    [/code]

    [This message has been edited by SepodatiCreations (edited October 02, 2000).]
  14. #8
  15. No Profile Picture
    fantom
    Guest
    Devshed Newbie (0 - 499 posts)
    Appreciate it very much...

Similar Threads

  1. maysqladmin drop database syntax?
    By Slurm in forum MySQL Help
    Replies: 1
    Last Post: February 17th, 2004, 05:07 AM
  2. Replies: 2
    Last Post: February 11th, 2004, 03:15 PM
  3. database design and paging question
    By emilyb in forum MySQL Help
    Replies: 12
    Last Post: February 5th, 2004, 01:31 PM
  4. Database select question
    By Lobos34 in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 06:49 PM
  5. Replies: 0
    Last Post: January 18th, 2004, 05:55 PM

IMN logo majestic logo threadwatch logo seochat tools logo