Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have this small project I have been working on. I have a MySQL table that looks kind of like this

+---------+-------------+------+
| Content | Date Posted | Name |
+---------+-------------+------+
| Content | Date Posted | Name |
+---------+-------------+------+

And I need a PHP script to read the top 10 rows from the database, based on date posted.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
262 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use PHPMyAdmin to create tables, or run a script like this:

CREATE TABLE Contents (
  Content MEMO NOT NULL,
  DatePosted DATE NOT NULL,
  Name VARCHAR2(200) NOT NULL);

and select the newest 10 like this:

SELECT
  t.Content,
  t.DatePosted,
  t.Name
FROM
  Contents t
ORDER BY
  DatePosted DESC
LIMIT 10

But while the answer seems small, it is actually a big question. Do you have no idea whatsoever? Maybe you should start by reading some tutorials if you don't want to get stuck every time you need a little something from your database.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...