October 1st, 2000, 12:36 PM
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.
October 1st, 2000, 01:14 PM
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.
October 1st, 2000, 01:47 PM
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..
October 1st, 2000, 04:28 PM
Ok, I gave up on that date function for the time being... but I have another task:
If my table looks like this:
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?
October 1st, 2000, 07:19 PM
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;
October 1st, 2000, 08:06 PM
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).]
October 2nd, 2000, 02:32 AM
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$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"];
[This message has been edited by SepodatiCreations (edited October 02, 2000).]
October 2nd, 2000, 02:40 AM
Appreciate it very much...