MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 1st, 2000, 11:36 AM
fantom
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
  #2  
Old October 1st, 2000, 12:14 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
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.

Reply With Quote
  #3  
Old October 1st, 2000, 12:47 PM
fantom
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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..

Reply With Quote
  #4  
Old October 1st, 2000, 03:28 PM
fantom
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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?

Reply With Quote
  #5  
Old October 1st, 2000, 06:19 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
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;


Reply With Quote
  #6  
Old October 1st, 2000, 07:06 PM
fantom
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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).]

Reply With Quote
  #7  
Old October 2nd, 2000, 01:32 AM
Sepodati's Avatar
Sepodati Sepodati is offline
Banned
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Dec 1999
Location: Afghanistan
Posts: 14,385 Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)Sepodati User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 72383 Folding Title: Intermediate FolderFolding Points: 72383 Folding Title: Intermediate FolderFolding Points: 72383 Folding Title: Intermediate FolderFolding Points: 72383 Folding Title: Intermediate Folder
Time spent in forums: 2 Months 4 Weeks 19 h 40 m 36 sec
Reputation Power: 1784
Send a message via ICQ to Sepodati Send a message via Yahoo to Sepodati
<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).]

Reply With Quote
  #8  
Old October 2nd, 2000, 01:40 AM
fantom
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Appreciate it very much...

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Database Question....


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT