Simple CMS mySQL / PHP

白昼怎懂夜的黑 提交于 2019-12-13 08:17:03

问题


Okay, so 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.


回答1:


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.



来源:https://stackoverflow.com/questions/4928370/simple-cms-mysql-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!